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

Function timings_out

IPython/utils/timing.py:80–111  ·  view source on GitHub ↗

timings_out(reps,func,*args,**kw) -> (t_total,t_per_call,output) Execute a function reps times, return a tuple with the elapsed total CPU time in seconds, the time per call and the function's output. Under Unix, the return value is the sum of user+system time consumed by the proces

(
    reps: int,
    func: Callable[..., Any],
    *args: Any,
    **kw: Any,
)

Source from the content-addressed store, hash-verified

78
79
80def timings_out(
81 reps: int,
82 func: Callable[..., Any],
83 *args: Any,
84 **kw: Any,
85) -> tuple[float, float, Any]:
86 """timings_out(reps,func,*args,**kw) -> (t_total,t_per_call,output)
87
88 Execute a function reps times, return a tuple with the elapsed total
89 CPU time in seconds, the time per call and the function's output.
90
91 Under Unix, the return value is the sum of user+system time consumed by
92 the process, computed via the resource module. This prevents problems
93 related to the wraparound effect which the time.clock() function has.
94
95 Under Windows the return value is in wall clock seconds. See the
96 documentation for the time module for more details."""
97
98 reps = int(reps)
99 assert reps >=1, 'reps must be >= 1'
100 if reps==1:
101 start = clock()
102 out = func(*args,**kw)
103 tot_time = clock()-start
104 else:
105 rng = range(reps-1) # the last time is executed separately to store output
106 start = clock()
107 for dummy in rng: func(*args,**kw)
108 out = func(*args,**kw) # one last time
109 tot_time = clock()-start
110 av_time = tot_time / reps
111 return tot_time,av_time,out
112
113
114def timings(

Callers 2

timingsFunction · 0.85
timingFunction · 0.85

Calls 2

clockFunction · 0.85
funcFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…