From 9fc787433678a2b98191d81eb1694fb349e0b6f8 Mon Sep 17 00:00:00 2001 From: Kevin Wan Date: Sat, 6 May 2023 15:31:56 +0800 Subject: [PATCH] chore: optimize stat calculation (#3213) --- core/stat/metrics.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/stat/metrics.go b/core/stat/metrics.go index f0efe1e9..5b0809b9 100644 --- a/core/stat/metrics.go +++ b/core/stat/metrics.go @@ -141,7 +141,7 @@ func (c *metricsContainer) Execute(v any) { report.Median = float32(medianTask.Duration) / float32(time.Millisecond) tenPercent := fiftyPercent / 5 if tenPercent > 0 { - top10pTasks := topK(tasks, tenPercent) + top10pTasks := topK(top50pTasks, tenPercent) task90th := top10pTasks[0] report.Top90th = float32(task90th.Duration) / float32(time.Millisecond) onePercent := tenPercent / 10 @@ -163,7 +163,7 @@ func (c *metricsContainer) Execute(v any) { report.Top99p9th = mostDuration } } else { - mostDuration := getTopDuration(tasks) + mostDuration := getTopDuration(top50pTasks) report.Top90th = mostDuration report.Top99th = mostDuration report.Top99p9th = mostDuration