##// END OF EJS Templates
use time.process_time instead of perf_counter...
Bastian Ebeling -
Show More
@@ -0,0 +1,6 b''
1 windows time-implementation: Switch to process_time
2 ===================================================
3 Timing for example with ``%%time`` on windows is based on ``time.perf_counter``.
4 This is at the end the same as W-All.
5 To be a bit tighter to linux one could change to ``time.process_time`` instead.
6 Thus for example one would no longer count periods of sleep and further.
@@ -1326,19 +1326,22 b' class ExecutionMagics(Magics):'
1326
1326
1327 wall_end = wtime()
1327 wall_end = wtime()
1328 # Compute actual times and report
1328 # Compute actual times and report
1329 wall_time = wall_end-wall_st
1329 wall_time = wall_end - wall_st
1330 cpu_user = end[0]-st[0]
1330 cpu_user = end[0] - st[0]
1331 cpu_sys = end[1]-st[1]
1331 cpu_sys = end[1] - st[1]
1332 cpu_tot = cpu_user+cpu_sys
1332 cpu_tot = cpu_user + cpu_sys
1333 # On windows cpu_sys is always zero, so no new information to the next print
1333 # On windows cpu_sys is always zero, so only total is displayed
1334 if sys.platform != 'win32':
1334 if sys.platform != "win32":
1335 print("CPU times: user %s, sys: %s, total: %s" % \
1335 print(
1336 (_format_time(cpu_user),_format_time(cpu_sys),_format_time(cpu_tot)))
1336 f"CPU times: user {_format_time(cpu_user)}, sys: {_format_time(cpu_sys)}, total: {_format_time(cpu_tot)}"
1337 print("Wall time: %s" % _format_time(wall_time))
1337 )
1338 else:
1339 print(f"CPU times: total: {_format_time(cpu_tot)}")
1340 print(f"Wall time: {_format_time(wall_time)}")
1338 if tc > tc_min:
1341 if tc > tc_min:
1339 print("Compiler : %s" % _format_time(tc))
1342 print(f"Compiler : {_format_time(tc)}")
1340 if tp > tp_min:
1343 if tp > tp_min:
1341 print("Parser : %s" % _format_time(tp))
1344 print(f"Parser : {_format_time(tp)}")
1342 return out
1345 return out
1343
1346
1344 @skip_doctest
1347 @skip_doctest
@@ -64,14 +64,14 b' if resource is not None and hasattr(resource, "getrusage"):'
64
64
65 else:
65 else:
66 # There is no distinction of user/system time under windows, so we just use
66 # There is no distinction of user/system time under windows, so we just use
67 # time.perff_counter() for everything...
67 # time.process_time() for everything...
68 clocku = clocks = clock = time.perf_counter
68 clocku = clocks = clock = time.process_time
69
69
70 def clock2():
70 def clock2():
71 """Under windows, system CPU time can't be measured.
71 """Under windows, system CPU time can't be measured.
72
72
73 This just returns perf_counter() and zero."""
73 This just returns process_time() and zero."""
74 return time.perf_counter(),0.0
74 return time.process_time(), 0.0
75
75
76
76
77 def timings_out(reps,func,*args,**kw):
77 def timings_out(reps,func,*args,**kw):
@@ -23,6 +23,8 b' Need to be updated:'
23 pr/*
23 pr/*
24
24
25
25
26
27
26 .. DO NOT EDIT THIS LINE BEFORE RELEASE. FEATURE INSERTION POINT.
28 .. DO NOT EDIT THIS LINE BEFORE RELEASE. FEATURE INSERTION POINT.
27
29
28 Backwards incompatible changes
30 Backwards incompatible changes
General Comments 0
You need to be logged in to leave comments. Login now