Move time tracking functions to separate file.
Former-commit-id: ccecc95fd70f36208fa01b3b4d2c7bdd1546ff92
This commit is contained in:
parent
da45e0fdb4
commit
3a1f7c95aa
|
@ -8,35 +8,7 @@ import scipy
|
||||||
import sys
|
import sys
|
||||||
from qpms_c import get_mn_y, trans_calculator # TODO be explicit about what is imported
|
from qpms_c import get_mn_y, trans_calculator # TODO be explicit about what is imported
|
||||||
from .qpms_p import cart2sph, nelem2lMax # TODO be explicit about what is imported
|
from .qpms_p import cart2sph, nelem2lMax # TODO be explicit about what is imported
|
||||||
|
from .timetrack import _time_b, _time_e
|
||||||
def _time_b(active = True, name = None, step = None):
|
|
||||||
'''
|
|
||||||
Auxiliary function for keeping track of elapsed time.
|
|
||||||
Returns current time (to be used by _time_e).
|
|
||||||
'''
|
|
||||||
now = time.time()
|
|
||||||
if active:
|
|
||||||
if not name:
|
|
||||||
name = sys._getframe(1).f_code.co_name
|
|
||||||
if step:
|
|
||||||
print('%.4f: %s in function %s started.' % (now, step, name), file = sys.stderr)
|
|
||||||
else:
|
|
||||||
print('%.4f: Function %s started.' % (now, name), file=sys.stderr)
|
|
||||||
sys.stderr.flush()
|
|
||||||
return now
|
|
||||||
|
|
||||||
def _time_e(start_time, active = True, name = None, step = None):
|
|
||||||
now = time.time()
|
|
||||||
if active:
|
|
||||||
if not name:
|
|
||||||
name = sys._getframe(1).f_code.co_name
|
|
||||||
if step:
|
|
||||||
print('%.4f: %s in function %s finished (elapsed %.2f s).'
|
|
||||||
% (now, step, name, now - start_time), file = sys.stderr)
|
|
||||||
else:
|
|
||||||
print('%.4f: Function %s finished (elapsed %.2f s).'
|
|
||||||
% (now, name, now - start_time), file = sys.stderr)
|
|
||||||
sys.stderr.flush()
|
|
||||||
|
|
||||||
class Scattering(object):
|
class Scattering(object):
|
||||||
'''
|
'''
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
import time
|
||||||
|
import sys
|
||||||
|
|
||||||
|
def _time_b(active = True, name = None, step = None):
|
||||||
|
'''
|
||||||
|
Auxiliary function for keeping track of elapsed time.
|
||||||
|
Returns current time (to be used by _time_e).
|
||||||
|
'''
|
||||||
|
now = time.time()
|
||||||
|
if active:
|
||||||
|
if not name:
|
||||||
|
name = sys._getframe(1).f_code.co_name
|
||||||
|
if step:
|
||||||
|
print('%.4f: %s in function %s started.' % (now, step, name), file = sys.stderr)
|
||||||
|
else:
|
||||||
|
print('%.4f: Function %s started.' % (now, name), file=sys.stderr)
|
||||||
|
sys.stderr.flush()
|
||||||
|
return now
|
||||||
|
|
||||||
|
def _time_e(start_time, active = True, name = None, step = None):
|
||||||
|
now = time.time()
|
||||||
|
if active:
|
||||||
|
if not name:
|
||||||
|
name = sys._getframe(1).f_code.co_name
|
||||||
|
if step:
|
||||||
|
print('%.4f: %s in function %s finished (elapsed %.2f s).'
|
||||||
|
% (now, step, name, now - start_time), file = sys.stderr)
|
||||||
|
else:
|
||||||
|
print('%.4f: Function %s finished (elapsed %.2f s).'
|
||||||
|
% (now, name, now - start_time), file = sys.stderr)
|
||||||
|
sys.stderr.flush()
|
||||||
|
|
Loading…
Reference in New Issue