Skip to content

Commit

Permalink
Skip invalid samples.
Browse files Browse the repository at this point in the history
  • Loading branch information
emeryberger committed Sep 4, 2023
1 parent 160e03e commit 08812de
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions scalene/scalene_profiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -1097,6 +1097,11 @@ def process_cpu_sample(
# CPU utilization is the fraction of time spent on the CPU
# over the total time.
elapsed_user = now_user - prev_user
if any([elapsed_virtual < 0, elapsed_wallclock < 0, elapsed_user < 0]):
# If we get negative values, which appear to arise in some
# multi-process settings (seen in gunicorn), skip this
# sample.
return
cpu_utilization = 0.0
if elapsed_wallclock != 0:
cpu_utilization = elapsed_user / elapsed_wallclock
Expand Down

0 comments on commit 08812de

Please # to comment.