From: Ondrej Lichtner <olichtne(a)redhat.com>
The original calculation creates the ratio of the "used" cpu time vs the
elapsed real time, however to create a percentage we need to multiply by
100. Without this fix the reported values were always between 0 and 1
would seem confusing in the context of other cpu metrics where a 0 to
100 value is reported.
At the same time, the PerfInterval value should be multiplied by the
actual duration of the interval so that the average calculation makes
sense. This is required for metrics that don't represent a useful
"cumulative" unit/metric - throughput is a metric that accumulates
transferred bytes over time, however percentage cpu utilization doesn't
accumulate over time.
Without this fix, sometimes a short start or end interval (e.g. duration
of 0.00005 seconds) would end up confusing and poisoning the calculation
of the entire Sequence of Intervals.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
---
lnst/RecipeCommon/Perf/Measurements/NeperFlowMeasurement.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/lnst/RecipeCommon/Perf/Measurements/NeperFlowMeasurement.py
b/lnst/RecipeCommon/Perf/Measurements/NeperFlowMeasurement.py
index f271e1b3..1e05b8e0 100644
--- a/lnst/RecipeCommon/Perf/Measurements/NeperFlowMeasurement.py
+++ b/lnst/RecipeCommon/Perf/Measurements/NeperFlowMeasurement.py
@@ -220,9 +220,9 @@ def get_interval(s_start: Dict, s_end: Dict, job_start: float,
# unix time using job_start as reference
timestamp = job_start + (s_start_time - neper_start)
duration = s_end_time - s_start_time
- cpu_usage = (utime_delta + stime_delta) / duration
+ cpu_usage = ((utime_delta + stime_delta) / duration) * 100
interval = PerfInterval(transactions, duration, 'transactions', timestamp)
- cpu_interval = PerfInterval(cpu_usage, duration, 'cpu_percent', timestamp)
+ cpu_interval = PerfInterval(cpu_usage * duration, duration, 'cpu_percent',
timestamp)
return interval, cpu_interval
--
2.31.1
Show replies by date