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