mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00:00
app/vmselect/promql: fix corner-case calculation for ideriv
This commit is contained in:
parent
639b14e8ab
commit
d6b5ed6d39
2 changed files with 3 additions and 3 deletions
|
@ -698,7 +698,7 @@ func rollupIderiv(rfa *rollupFuncArg) float64 {
|
|||
// It is impossible to calculate derivative on 0 or 1 values.
|
||||
return nan
|
||||
}
|
||||
return (values[0] - rfa.prevValue) / float64(timestamps[0]-rfa.prevTimestamp)
|
||||
return (values[0] - rfa.prevValue) / (float64(timestamps[0]-rfa.prevTimestamp) * 1e-3)
|
||||
}
|
||||
vEnd := values[len(values)-1]
|
||||
tEnd := timestamps[len(timestamps)-1]
|
||||
|
@ -722,7 +722,7 @@ func rollupIderiv(rfa *rollupFuncArg) float64 {
|
|||
}
|
||||
dv := vEnd - vStart
|
||||
dt := tEnd - tStart
|
||||
return dv / (float64(dt) / 1000)
|
||||
return dv / (float64(dt) * 1e-3)
|
||||
}
|
||||
|
||||
func rollupChanges(rfa *rollupFuncArg) float64 {
|
||||
|
|
|
@ -56,7 +56,7 @@ func TestRollupIderivDuplicateTimestamps(t *testing.T) {
|
|||
timestamps: []int64{100},
|
||||
}
|
||||
n = rollupIderiv(rfa)
|
||||
if n != 0.5 {
|
||||
if n != 500 {
|
||||
t.Fatalf("unexpected value; got %v; want %v", n, 0.5)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue