提交 4a8f5164 authored 作者: Frederic's avatar Frederic

put the profile in the env to allow better reuse of it later.

上级 79fd771a
......@@ -1030,6 +1030,8 @@ class FunctionMaker(object):
# make the env (copies the graph, creates NEW INPUT AND OUTPUT VARIABLES)
env, additional_outputs = std_env(expanded_inputs, outputs, accept_inplace)
env.profile = profile
self.env = env
# Fetch the optimizer and linker
......@@ -1049,7 +1051,6 @@ class FunctionMaker(object):
mode.optimizer_time += opt_time
if profile:
profile.optimizer_time += opt_time
profile.validate_time += env.validate_time
_logger.debug('Optimizing took %f seconds', opt_time)
#Add deep copy to respect the memory interface
......
......@@ -53,8 +53,11 @@ def _atexit_print_fn():
# for ps in [ps for ps in _atexit_print_list[1:]
# if not isinstance(ps, ScanProfileStats)]:
for attr in ["compile_time", "fct_call_time", "fct_callcount",
"vm_call_time", "optimizer_time", "linker_time"]:
"vm_call_time", "optimizer_time", "linker_time",
"validate_time"]:
setattr(cum, attr, getattr(cum, attr) + getattr(ps, attr))
#merge dictonary
for attr in ["apply_time", "apply_callcount",
"apply_cimpl", "outputs_size"]:
cum_attr = getattr(cum, attr)
......
......@@ -128,6 +128,7 @@ class Env(utils.object2):
self.node_locks = {}
self.variable_locks = {}
self.profile = None
### Setup a Variable ###
......
......@@ -154,7 +154,8 @@ class SeqOptimizer(Optimizer, list):
Applies each L{Optimizer} in self in turn.
"""
l = []
validate_before = env.validate_time
if env.profile:
validate_before = env.profile.validate_time
nb_node_before = len(env.nodes)
for optimizer in self:
try:
......@@ -176,7 +177,7 @@ class SeqOptimizer(Optimizer, list):
elif hasattr(self,"__name__"): print self.__name__,
print " time %.3fs for %d/%d nodes before/after optimization"%(sum(l),nb_node_before,len(env.nodes))
print " time %.3fs for validate " % (
env.validate_time - validate_before)
env.profile.validate_time - validate_before)
ll=[]
for opt in self:
if hasattr(opt,"__name__"):
......
......@@ -72,11 +72,11 @@ class Validator:
t0 = time.time()
ret = env.execute_callbacks('validate')
t1 = time.time()
env.validate_time += t1 - t0
if env.profile:
env.profile.validate_time += t1 - t0
return ret
env.validate = validate
env.validate_time = 0
def consistent():
try:
......@@ -89,7 +89,6 @@ class Validator:
def on_detach(self, env):
del env.validate
del env.consistent
del env.validate_time
class ReplaceValidate(History, Validator):
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论