提交 9bde025e authored 作者: Razvan Pascanu's avatar Razvan Pascanu

merge

...@@ -240,9 +240,22 @@ def get_mode(string): ...@@ -240,9 +240,22 @@ def get_mode(string):
raise Exception("No predefixed mode exist for string: %s"%string) raise Exception("No predefixed mode exist for string: %s"%string)
return predefined_modes[string] return predefined_modes[string]
instanciated_default_mode=None
def get_default_mode(): def get_default_mode():
global instanciated_default_mode
if config.mode in ['Mode','ProfileMode','DebugMode']: if config.mode in ['Mode','ProfileMode','DebugMode']:
return Mode(linker=config.linker, optimizer=config.optimizer) if instanciated_default_mode:
return instanciated_default_mode
#need to import later to break circular dependency.
from profilemode import ProfileMode,prof_mode_instance_to_print
from debugmode import DebugMode
import pdb;pdb.set_trace()
instanciated_default_mode = eval(config.mode+'(linker=config.linker, optimizer=config.optimizer)')
#must tell python to print the summary at the end.
if config.mode == 'ProfileMode':
prof_mode_instance_to_print.append(instanciated_default_mode)
return instanciated_default_mode
return get_mode(config.mode) return get_mode(config.mode)
default_mode = config.mode default_mode = config.mode
......
...@@ -324,13 +324,16 @@ class ProfileMode(Mode): ...@@ -324,13 +324,16 @@ class ProfileMode(Mode):
register_mode('PROFILE_MODE',ProfileMode()) register_mode('PROFILE_MODE',ProfileMode())
#needed to print the profile at the end automatically
prof_mode_instance_to_print=[predefined_modes["PROFILE_MODE"]]
def atexit_print_default_profile_mode(): def atexit_print_default_profile_mode():
"""Print the summary of the predefined mode PROFILE_MODE if used. """Print the summary of the predefined mode PROFILE_MODE if used.
This all to have the summary printed at exit when This all to have the summary printed at exit when
config.mode=PROFILE_MODE config.mode=PROFILE_MODE
""" """
prof_mode=predefined_modes["PROFILE_MODE"] for prof_mode in prof_mode_instance_to_print:
if prof_mode.local_time[0]>0: if prof_mode.local_time[0]>0:
prof_mode.print_summary() prof_mode.print_summary()
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论