提交 05b84df9 authored 作者: Faruk Ahmed's avatar Faruk Ahmed

create func for global stats

上级 70129ffb
......@@ -941,6 +941,7 @@ class Function(object):
if profile:
profile.fct_callcount += 1
profile.fct_call_time += dt_call
profile.total_fct_exec_time += dt_call
if hasattr(self.fn, 'update_profile'):
self.fn.update_profile(profile)
if profile.ignore_first_call:
......@@ -1468,6 +1469,7 @@ class FunctionMaker(object):
opt_time = end_optimizer - start_optimizer
if profile:
profile.optimizer_time += opt_time
profile.total_graph_opt_time += opt_time
if theano.config.profile_optimizer:
profile.optimizer_profile = (optimizer,
optimizer_profile)
......@@ -1658,6 +1660,7 @@ class FunctionMaker(object):
_logger.debug('Linker took %f seconds', linker_time)
if self.profile:
self.profile.linker_time += linker_time
self.profile.total_time_linker += linker_time
_fn.time_thunks = self.profile.flag_time_thunks
import_time = theano.gof.cmodule.import_time - start_import_time
self.profile.import_time += import_time
......
......@@ -36,6 +36,9 @@ from theano.gof import graph
logger = logging.getLogger('theano.compile.profiling')
theano_imported_time = time.time()
total_fct_exec_time = 0.
total_graph_opt_time = 0.
total_time_linker = 0.
config = theano.config
_atexit_print_list = []
......@@ -109,6 +112,34 @@ def _atexit_print_fn():
n_apply_to_print=config.profiling.n_apply)
def print_global_stats():
"""
Print the following stats:
-- Time elapsed since Theano was imported
-- Time spent inside Theano functions
-- Time spent in compiling Theano functions
-- on graph optimization
-- on linker
"""
if config.profiling.destination == 'stderr':
destination_file = sys.stderr
elif config.profiling.destination == 'stdout':
destination_file = sys.stdout
else:
destination_file = open(config.profiling.destination, 'w')
print('Time elasped since Theano import = %6.2fs, '
'Time spent in Theano functions = %6.2fs, '
'Time spent compiling Theano functions: '
' optimzation = %6.2s, linker = %6.2s ' %
(theano_imported_time,
total_fct_exec_time,
total_graph_opt_time,
total_time_linker),
file=file)
class ProfileStats(object):
"""
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论