From 11749a17fbf5af0aa970269a182502e2eadb7c33 Mon Sep 17 00:00:00 2001 From: Gerhard Bogner <32961369+bogi788@users.noreply.github.com> Date: Mon, 13 Oct 2025 18:43:53 +0200 Subject: [PATCH] console: fix index 95th percentile (#2021) * fix index 95th percentile * go fmt, update expected 95th percentile test results --- console/line.go | 2 +- console/line_test.go | 100 +++++++++++++++++++++---------------------- 2 files changed, 51 insertions(+), 51 deletions(-) diff --git a/console/line.go b/console/line.go index 8473dc4d..3758698a 100644 --- a/console/line.go +++ b/console/line.go @@ -427,7 +427,7 @@ func (c *Component) graphLineHandlerFunc(gc *gin.Context) { // Max output.Max[i] = points[nbPoints-1] // 95th percentile with linear interpolation - index := 0.95*float64(nbPoints) - 1 + index := 0.95 * float64(nbPoints-1) j := int(index) fraction := index - float64(j) output.NinetyFivePercentile[i] = points[nbPoints-1] diff --git a/console/line_test.go b/console/line_test.go index 558f39fb..83ac74c0 100644 --- a/console/line_test.go +++ b/console/line_test.go @@ -1002,12 +1002,12 @@ func TestGraphLineHandler(t *testing.T) { 700, }, "95th": []int{ - 4700, - 925, - 1020, - 935, - 780, - 1630, + 4800, + 950, + 1080, + 990, + 820, + 1720, }, "axis": []int{ 1, 1, 1, 1, 1, 1, @@ -1128,19 +1128,19 @@ func TestGraphLineHandler(t *testing.T) { 70, }, "95th": []int{ - 4700, - 925, - 1020, - 935, - 780, - 1630, + 4800, + 950, + 1080, + 990, + 820, + 1720, - 470, - 93, - 102, - 94, - 78, - 163, + 480, + 96, + 108, + 100, + 82, + 172, }, "axis": []int{ 1, 1, 1, 1, 1, 1, @@ -1228,13 +1228,13 @@ func TestGraphLineHandler(t *testing.T) { 6166, }, "95th": []int{ - 4700, - 925, - 1020, - 935, - 780, - 1630, - 7700, + 4800, + 950, + 1080, + 990, + 820, + 1720, + 7800, }, "axis": []int{ 1, 1, 1, 1, 1, 1, @@ -1424,12 +1424,12 @@ func TestGraphLineHandler(t *testing.T) { 700, }, "95th": []int{ - 4700, - 1020, - 935, - 925, - 780, - 1630, + 4800, + 1080, + 990, + 950, + 820, + 1720, }, "axis": []int{ 1, 1, 1, 1, 1, 1, @@ -1550,19 +1550,19 @@ func TestGraphLineHandler(t *testing.T) { 70, }, "95th": []int{ - 4700, - 1020, - 935, - 925, - 780, - 1630, + 4800, + 1080, + 990, + 950, + 820, + 1720, - 470, - 102, - 94, - 93, - 78, - 163, + 480, + 108, + 100, + 96, + 82, + 172, }, "axis": []int{ 1, 1, 1, 1, 1, 1, @@ -1650,13 +1650,13 @@ func TestGraphLineHandler(t *testing.T) { 6166, }, "95th": []int{ - 4700, - 1020, - 935, - 925, - 780, - 1630, - 7700, + 4800, + 1080, + 990, + 950, + 820, + 1720, + 7800, }, "axis": []int{ 1, 1, 1, 1, 1, 1,