#NEWLINE# def write_profile( profile_f , features , extraction_durations , combined_profile ) : #NEWLINE# #INDENT# profile_f . write ( 'Extracting {0} features\n\n' . format ( len ( misc_profiles ) ) ) #NEWLINE# table = tabulate ( [ ( 'extractions' , len ( extraction_durations ) ) , ( 'total_time' , round ( sum ( extraction_durations ) , 3 ) ) , ( 'min_time' , round ( min ( extraction_durations ) , 3 ) ) , ( 'max_time' , round ( max ( extraction_durations ) , 3 ) ) , ( 'mean_time' , round ( mean ( extraction_durations ) , 3 ) ) , ( 'median_time' , round ( median ( extraction_durations ) , 3 ) ) ] , headers = [ 'stat' , 'value' ] , tablefmt = 'pipe' ) #NEWLINE# profile_f . write ( ( table + '\n' ) ) #NEWLINE# profile_f . write ( '\n' ) #NEWLINE# feature_profiles = [ ] #NEWLINE# datasource_profiles = [ ] #NEWLINE# misc_profiles = [ ] #NEWLINE# for ( dependent_name , durations ) in combined_profile . items ( ) : #NEWLINE# #INDENT# row = ( dependent_name . replace ( '<' , '\\<' ) . replace ( '>' , '\\>' ) , len ( durations ) , round ( min ( durations ) , 3 ) , round ( max ( durations ) , 3 ) , round ( mean ( durations ) , 3 ) , round ( median ( durations ) , 3 ) ) #NEWLINE# if ( 'feature.' in dependent_name ) : #NEWLINE# #INDENT# feature_profiles . append ( row ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( 'datasource.' in dependent_name ) : #NEWLINE# #INDENT# datasource_profiles . append ( row ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# misc_profiles . append ( row ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# profile_f . write ( '# Features\n' ) #NEWLINE# write_dependent_profiles ( profile_f , feature_profiles ) #NEWLINE# profile_f . write ( '# Datasources\n' ) #NEWLINE# write_dependent_profiles ( profile_f , datasource_profiles ) #NEWLINE# profile_f . write ( '# Misc\n' ) #NEWLINE# write_dependent_profiles ( profile_f , misc_profiles )