From dfad7a331b11d74c6cd77b4706e54e62549de815 Mon Sep 17 00:00:00 2001 From: Emery Berger Date: Fri, 18 Oct 2024 16:11:44 -0400 Subject: [PATCH] Round down to avoid spuriously crossing 100% threshold. --- scalene/scalene_json.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scalene/scalene_json.py b/scalene/scalene_json.py index 5003cdca5..ede7a113b 100644 --- a/scalene/scalene_json.py +++ b/scalene/scalene_json.py @@ -43,14 +43,14 @@ class FunctionDetail(BaseModel): @model_validator(mode="after") def check_cpu_percentages(cls, values): - total_cpu_usage = math.ceil( + total_cpu_usage = math.floor( values.n_cpu_percent_c + values.n_cpu_percent_python + values.n_sys_percent ) if total_cpu_usage > 100: raise ValueError( - f"The sum of n_cpu_percent_c, n_cpu_percent_python, and n_sys_percent must be < 100 but is {total_cpu_usage}" + f"The sum of n_cpu_percent_c, n_cpu_percent_python, and n_sys_percent must be <= 100 but is {total_cpu_usage}" ) return values