feat: add always enabled to execution time

This commit is contained in:
Jan De Dobbeleer 2020-12-12 12:53:06 +01:00 committed by Jan De Dobbeleer
parent 1777f1df38
commit d5b41b37b2
3 changed files with 9 additions and 2 deletions

View file

@ -29,10 +29,10 @@ To use this, use the PowerShell module, or confirm that you are passing an `exec
## Properties
- always_enabled: `boolean` - always show the duration - defaults to `false`
- threshold: `number` - minimum duration (milliseconds) required to enable this segment - defaults to `500`
- style: `enum` - one of the available format options - defaults to `austin`
## Style
Style specifies the format in which the time will be displayed. The table below shows some example times in each option.

View file

@ -37,9 +37,10 @@ const (
)
func (t *executiontime) enabled() bool {
alwaysEnabled := t.props.getBool(AlwaysEnabled, false)
executionTimeMs := t.env.executionTime()
thresholdMs := t.props.getFloat64(ThresholdProperty, float64(500))
if executionTimeMs < thresholdMs {
if !alwaysEnabled && executionTimeMs < thresholdMs {
return false
}
style := DurationStyle(t.props.getString(Style, string(Austin)))

View file

@ -1145,6 +1145,12 @@
"properties": {
"properties": {
"properties": {
"always_enabled": {
"type": "boolean",
"title": "Always Enabled",
"description": "Always show the duration",
"default": false
},
"threshold": {
"type": "number",
"title": "Threshold",