ATLAS Offline Software
Loading...
Searching...
No Matches
python.rtime Namespace Reference

Functions

 rtime (fn, *args, **kw)

Function Documentation

◆ rtime()

python.rtime.rtime ( fn,
* args,
** kw )
Call FN with the additional arguments passed in.
Print a report of the CPU time taken.

Definition at line 14 of file rtime.py.

14def rtime (fn, *args, **kw):
15 """Call FN with the additional arguments passed in.
16Print a report of the CPU time taken.
17"""
18 ru0 = resource.getrusage (resource.RUSAGE_SELF)
19 ret = None
20 try:
21 ret = fn (*args, **kw)
22 finally:
23 ru1 = resource.getrusage (resource.RUSAGE_SELF)
24 print ("utime: %f, stime: %f" % (ru1.ru_utime-ru0.ru_utime,
25 ru1.ru_stime-ru0.ru_stime))
26 return ret
27
28