3db03791e8
Add timerlat as a measurement module Resolves: RHEL-28058 Signed-off-by: John Kacur <jkacur@redhat.com>
61 lines
2.3 KiB
Diff
61 lines
2.3 KiB
Diff
From 071bd1be404f1b5c71f8b2f2d9fa1a85bd485ce9 Mon Sep 17 00:00:00 2001
|
|
From: John Kacur <jkacur@redhat.com>
|
|
Date: Thu, 25 Apr 2024 13:48:05 -0400
|
|
Subject: [PATCH 05/13] rteval: cyclictest.py: Fix the median calculation
|
|
|
|
Fix the calculation of the median in rteval for cyclictest
|
|
|
|
Signed-off-by: John Kacur <jkacur@redhat.com>
|
|
---
|
|
rteval/modules/measurement/cyclictest.py | 20 ++++++++++++++------
|
|
1 file changed, 14 insertions(+), 6 deletions(-)
|
|
|
|
diff --git a/rteval/modules/measurement/cyclictest.py b/rteval/modules/measurement/cyclictest.py
|
|
index 1ba8b8b2323c..cef73abd1b4b 100644
|
|
--- a/rteval/modules/measurement/cyclictest.py
|
|
+++ b/rteval/modules/measurement/cyclictest.py
|
|
@@ -80,26 +80,34 @@ class RunData:
|
|
return
|
|
|
|
self._log(Log.INFO, f"reducing {self.__id}")
|
|
- total = 0
|
|
+ total = 0 # total number of samples
|
|
+ total_us = 0
|
|
keys = list(self.__samples.keys())
|
|
keys.sort()
|
|
|
|
- mid = self.__numsamples / 2
|
|
+ # if numsamples is odd, then + 1 gives us the actual mid
|
|
+ # if numsamples is even, we avg mid and mid + 1, so we actually
|
|
+ # want to know mid + 1 since we will combine it with mid and
|
|
+ # the lastkey if the last key is at the end of a previous bucket
|
|
+ mid = int(self.__numsamples / 2) + 1
|
|
|
|
# mean, mode, and median
|
|
occurances = 0
|
|
lastkey = -1
|
|
for i in keys:
|
|
- if mid > total and mid <= (total + self.__samples[i]):
|
|
- if self.__numsamples & 1 and mid == total+1:
|
|
+ if mid > total and mid <= total + self.__samples[i]:
|
|
+ # Test if numsamples is even and if mid+1 is the next bucket
|
|
+ if self.__numsamples & 1 != 0 and mid == total+1:
|
|
self.__median = (lastkey + i) / 2
|
|
else:
|
|
self.__median = i
|
|
- total += (i * self.__samples[i])
|
|
+ lastkey = i
|
|
+ total += self.__samples[i]
|
|
+ total_us += (i * self.__samples[i])
|
|
if self.__samples[i] > occurances:
|
|
occurances = self.__samples[i]
|
|
self.__mode = i
|
|
- self.__mean = float(total) / float(self.__numsamples)
|
|
+ self.__mean = float(total_us) / float(self.__numsamples)
|
|
|
|
# range
|
|
for i in keys:
|
|
--
|
|
2.44.0
|
|
|