File tree 3 files changed +9
-4
lines changed
3 files changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -831,3 +831,6 @@ I: 2376
831
831
N: Anthony Ryan
832
832
W: https://github.com/anthonyryan1
833
833
I: 2272
834
+
835
+ N: Frank Kusters
836
+ I: 1586
Original file line number Diff line number Diff line change 20
20
21
21
**Bug fixes **
22
22
23
+ - 1586 _, `cpu_times_percent() `_ reports much too low values if the interval is
24
+ less than 1 second (with ``percpu=True ``) or less than ``1/cpu_count() ``
25
+ seconds (with ``percpu=False ``).
23
26
- 2395 _, [OpenBSD]: `pid_exists() `_ erroneously return True if the argument is
24
27
a thread ID (TID) instead of a PID (process ID).
25
28
- 2254 _, [Linux]: offline cpus raise NotImplementedError in cpu_freq() (patch by Shade Gladden)
Original file line number Diff line number Diff line change @@ -1846,10 +1846,9 @@ def calculate(t1, t2):
1846
1846
times_delta = _cpu_times_deltas (t1 , t2 )
1847
1847
all_delta = _cpu_tot_time (times_delta )
1848
1848
# "scale" is the value to multiply each delta with to get percentages.
1849
- # We use "max" to avoid division by zero (if all_delta is 0, then all
1850
- # fields are 0 so percentages will be 0 too. all_delta cannot be a
1851
- # fraction because cpu times are integers)
1852
- scale = 100.0 / max (1 , all_delta )
1849
+ # Avoid division by zero (if all_delta is 0, then all fields are 0 so
1850
+ # percentages will be 0 too).
1851
+ scale = 100.0 / all_delta if all_delta > 0 else 100.0
1853
1852
for field_delta in times_delta :
1854
1853
field_perc = field_delta * scale
1855
1854
field_perc = round (field_perc , 1 )
You can’t perform that action at this time.
0 commit comments