MCPcopy Index your code
hub / github.com/ipython/ipython / _run_with_timing

Method _run_with_timing

IPython/core/magics/execution.py:1023–1059  ·  view source on GitHub ↗

Run function `run` and print timing information. Parameters ---------- run : callable Any callable object which takes no argument. nruns : int Number of times to execute `run`.

(run, nruns)

Source from the content-addressed store, hash-verified

1021
1022 @staticmethod
1023 def _run_with_timing(run, nruns):
1024 """
1025 Run function `run` and print timing information.
1026
1027 Parameters
1028 ----------
1029 run : callable
1030 Any callable object which takes no argument.
1031 nruns : int
1032 Number of times to execute `run`.
1033
1034 """
1035 twall0 = time.perf_counter()
1036 if nruns == 1:
1037 t0 = clock2()
1038 run()
1039 t1 = clock2()
1040 t_usr = t1[0] - t0[0]
1041 t_sys = t1[1] - t0[1]
1042 print("\nIPython CPU timings (estimated):")
1043 print(" User : %10.2f s." % t_usr)
1044 print(" System : %10.2f s." % t_sys)
1045 else:
1046 runs = range(nruns)
1047 t0 = clock2()
1048 for nr in runs:
1049 run()
1050 t1 = clock2()
1051 t_usr = t1[0] - t0[0]
1052 t_sys = t1[1] - t0[1]
1053 print("\nIPython CPU timings (estimated):")
1054 print("Total runs performed:", nruns)
1055 print(" Times : %10s %10s" % ('Total', 'Per run'))
1056 print(" User : %10.2f s, %10.2f s." % (t_usr, t_usr / nruns))
1057 print(" System : %10.2f s, %10.2f s." % (t_sys, t_sys / nruns))
1058 twall1 = time.perf_counter()
1059 print("Wall time: %10.2f s." % (twall1 - twall0))
1060
1061 @skip_doctest
1062 @no_var_expand

Callers 1

runMethod · 0.95

Calls 1

clock2Function · 0.90

Tested by

no test coverage detected