#NEWLINE# def _atexit_print_fn( ) : #NEWLINE# #INDENT# '\n    Print ProfileStat objects in _atexit_print_list to _atexit_print_file.\n\n    ' #NEWLINE# to_sum = [ ] #NEWLINE# if ( config . profiling . destination == 'stderr' ) : #NEWLINE# #INDENT# destination_file = sys . stderr #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( config . profiling . destination == 'stdout' ) : #NEWLINE# #INDENT# destination_file = sys . stdout #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# destination_file = open ( config . profiling . destination , 'w' ) #NEWLINE# #UNINDENT# #UNINDENT# for ps in _atexit_print_list : #NEWLINE# #INDENT# if ( ps . fct_callcount or ( ps . compile_time > 0 ) ) : #NEWLINE# #INDENT# ps . summary ( file = destination_file , n_ops_to_print = config . profiling . n_ops , n_apply_to_print = config . profiling . n_apply ) #NEWLINE# if ( not isinstance ( ps , ScanProfileStats ) ) : #NEWLINE# #INDENT# to_sum . append ( ps ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# print ( 'Skipping empty Profile' ) #NEWLINE# #UNINDENT# #UNINDENT# if ( len ( to_sum ) > 1 ) : #NEWLINE# #INDENT# cum = copy . copy ( to_sum [ 0 ] ) #NEWLINE# msg = ( 'Sum of all(%d) printed profiles at exit excluding Scan op profile.' % len ( to_sum ) ) #NEWLINE# cum . message = msg #NEWLINE# for ps in to_sum [ 1 : ] : #NEWLINE# #INDENT# for attr in [ 'compile_time' , 'fct_call_time' , 'fct_callcount' , 'vm_call_time' , 'optimizer_time' , 'linker_time' , 'validate_time' , 'import_time' ] : #NEWLINE# #INDENT# setattr ( cum , attr , ( getattr ( cum , attr ) + getattr ( ps , attr ) ) ) #NEWLINE# #UNINDENT# for attr in [ 'apply_time' , 'apply_callcount' , 'apply_cimpl' , 'variable_shape' , 'variable_strides' ] : #NEWLINE# #INDENT# cum_attr = getattr ( cum , attr ) #NEWLINE# for ( key , val ) in iteritems ( getattr ( ps , attr ) ) : #NEWLINE# #INDENT# assert ( key not in cum_attr ) #NEWLINE# cum_attr [ key ] = val #NEWLINE# #UNINDENT# #UNINDENT# if ( cum . optimizer_profile and ps . optimizer_profile ) : #NEWLINE# #INDENT# merge = cum . optimizer_profile [ 0 ] . merge_profile ( cum . optimizer_profile [ 1 ] , ps . optimizer_profile [ 1 ] ) #NEWLINE# cum . optimizer_profile = ( cum . optimizer_profile [ 0 ] , merge ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# cum . optimizer_profile = None #NEWLINE# #UNINDENT# #UNINDENT# cum . summary ( file = val , n_ops_to_print = config . profiling . n_ops , n_apply_to_print = config . profiling . n_apply )