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 |
|
1333 | # On windows cpu_sys is always zero, so only total is displayed | |
1334 |
if sys.platform != |
|
1334 | if sys.platform != "win32": | |
1335 | print("CPU times: user %s, sys: %s, total: %s" % \ |
|
1335 | print( | |
1336 |
|
|
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 : |
|
1342 | print(f"Compiler : {_format_time(tc)}") | |
1340 | if tp > tp_min: |
|
1343 | if tp > tp_min: | |
1341 |
print("Parser : |
|
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.p |
|
67 | # time.process_time() for everything... | |
68 |
clocku = clocks = clock = time.p |
|
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 p |
|
73 | This just returns process_time() and zero.""" | |
74 |
return time.p |
|
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): |
General Comments 0
You need to be logged in to leave comments.
Login now