#NEWLINE# def generate_default_report( self , output_csv = False ) : #NEWLINE# #INDENT# 'Format a default summary report based on calculated statistics for\n        an executed scenario.\n\n        :returns: A report (string) suitable for printing, emailing, etc.\n        ' #NEWLINE# stats = self . stats #NEWLINE# template = Template ( self . scenario_template ( ) ) #NEWLINE# tmpl_vars = { #NEWLINE# #INDENT# 'size_data' : [ ] , #NEWLINE# 'stat_list' : [ ( 'TOTAL' , stats [ 'agg_stats' ] , stats [ 'size_stats' ] ) , ( 'CREATE' , stats [ 'op_stats' ] [ ssbench . CREATE_OBJECT ] , stats [ 'op_stats' ] [ ssbench . CREATE_OBJECT ] [ 'size_stats' ] ) , ( 'READ' , stats [ 'op_stats' ] [ ssbench . READ_OBJECT ] , stats [ 'op_stats' ] [ ssbench . READ_OBJECT ] [ 'size_stats' ] ) , ( 'UPDATE' , stats [ 'op_stats' ] [ ssbench . UPDATE_OBJECT ] , stats [ 'op_stats' ] [ ssbench . UPDATE_OBJECT ] [ 'size_stats' ] ) , ( 'DELETE' , stats [ 'op_stats' ] [ ssbench . DELETE_OBJECT ] , stats [ 'op_stats' ] [ ssbench . DELETE_OBJECT ] [ 'size_stats' ] ) ] , #NEWLINE# 'agg_stats' : stats [ 'agg_stats' ] , #NEWLINE# 'nth_pctile' : stats [ 'nth_pctile' ] , #NEWLINE# 'start_time' : datetime . utcfromtimestamp ( stats [ 'time_series' ] [ 'start_time' ] ) . strftime ( REPORT_TIME_FORMAT ) , #NEWLINE# 'stop_time' : datetime . utcfromtimestamp ( stats [ 'time_series' ] [ 'stop' ] ) . strftime ( REPORT_TIME_FORMAT ) , #NEWLINE# 'duration' : ( stats [ 'time_series' ] [ 'stop' ] - stats [ 'time_series' ] [ 'start_time' ] ) , #NEWLINE# 'jobs_per_worker_stats' : stats [ 'jobs_per_worker_stats' ] , #NEWLINE# 'weighted_c' : 0.0 , #NEWLINE# 'weighted_r' : 0.0 , #NEWLINE# 'weighted_u' : 0.0 , #NEWLINE# 'weighted_d' : 0.0 , #NEWLINE# #UNINDENT# } #NEWLINE# for size_data in self . scenario . sizes_by_name . values ( ) : #NEWLINE# #INDENT# if ( size_data [ 'size_min' ] == size_data [ 'size_max' ] ) : #NEWLINE# #INDENT# size_range = ( '%-15s' % ( self . _format_bytes ( size_data [ 'size_min' ] ) , ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# size_range = ( '%s - %s' % ( self . _format_bytes ( size_data [ 'size_min' ] ) , self . _format_bytes ( size_data [ 'size_max' ] ) ) ) #NEWLINE# #UNINDENT# initial_files = self . scenario . _scenario_data [ 'initial_files' ] #NEWLINE# initial_total = sum ( initial_files . values ( ) ) #NEWLINE# pct_total = ( ( initial_files . get ( size_data [ 'name' ] , 0 ) / float ( initial_total ) ) * 100.0 ) #NEWLINE# tmpl_vars [ 'size_data' ] . append ( { #NEWLINE# #INDENT# 'crud_pcts' : '  ' . join ( map ( ( lambda p : ( '%2.0f' % p ) ) , size_data [ 'crud_pcts' ] ) ) , #NEWLINE# 'size_range' : size_range , #NEWLINE# 'size_name' : size_data [ 'name' ] , #NEWLINE# 'pct_total_ops' : ( '%3.0f%%' % pct_total ) , #NEWLINE# #UNINDENT# } ) #NEWLINE# tmpl_vars [ 'weighted_c' ] += ( ( pct_total * size_data [ 'crud_pcts' ] [ 0 ] ) / 100.0 ) #NEWLINE# tmpl_vars [ 'weighted_r' ] += ( ( pct_total * size_data [ 'crud_pcts' ] [ 1 ] ) / 100.0 ) #NEWLINE# tmpl_vars [ 'weighted_u' ] += ( ( pct_total * size_data [ 'crud_pcts' ] [ 2 ] ) / 100.0 ) #NEWLINE# tmpl_vars [ 'weighted_d' ] += ( ( pct_total * size_data [ 'crud_pcts' ] [ 3 ] ) / 100.0 ) #NEWLINE# #UNINDENT# if output_csv : #NEWLINE# #INDENT# csv_fields = [ 'scenario_name' , 'ssbench_version' , 'worker_count' , 'concurrency' , 'start_time' , 'stop_time' , 'duration' , 'delete_after' ] #NEWLINE# csv_data = { #NEWLINE# #INDENT# 'scenario_name' : self . scenario . name , #NEWLINE# 'ssbench_version' : self . scenario . version , #NEWLINE# 'worker_count' : tmpl_vars [ 'agg_stats' ] [ 'worker_count' ] , #NEWLINE# 'concurrency' : self . scenario . user_count , #NEWLINE# 'start_time' : tmpl_vars [ 'start_time' ] , #NEWLINE# 'stop_time' : tmpl_vars [ 'stop_time' ] , #NEWLINE# 'duration' : tmpl_vars [ 'duration' ] , #NEWLINE# 'delete_after' : str ( self . scenario . delete_after ) , #NEWLINE# #UNINDENT# } #NEWLINE# for ( label , stats , sstats ) in tmpl_vars [ 'stat_list' ] : #NEWLINE# #INDENT# label_lc = label . lower ( ) #NEWLINE# if stats . get ( 'req_count' , 0 ) : #NEWLINE# #INDENT# self . _add_csv_kv ( csv_fields , csv_data , ( '%s_count' % label_lc ) , stats [ 'req_count' ] ) #NEWLINE# self . _add_csv_kv ( csv_fields , csv_data , ( '%s_errors' % label_lc ) , initial_files [ 'errors' ] ) #NEWLINE# self . _add_csv_kv ( csv_fields , csv_data , ( '%s_retries' % label_lc ) , stats [ 'retries' ] ) #NEWLINE# self . _add_csv_kv ( csv_fields , csv_data , ( '%s_retry_rate' % label_lc ) , ( '%f' % stats [ 'retry_rate' ] ) ) #NEWLINE# self . _add_csv_kv ( csv_fields , csv_data , ( '%s_avg_req_per_s' % label_lc ) , stats [ 'avg_req_per_sec' ] ) #NEWLINE# self . _add_stats_for ( csv_fields , csv_data , label , 'all' , stats , tmpl_vars [ 'nth_pctile' ] ) #NEWLINE# for ( size_str , per_size_stats ) in sstats . iteritems ( ) : #NEWLINE# #INDENT# if per_size_stats : #NEWLINE# #INDENT# self . _add_stats_for ( csv_fields , csv_data , label , size_str , per_size_stats , tmpl_vars [ 'nth_pctile' ] ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# csv_file = StringIO ( ) #NEWLINE# csv_writer = DictWriter ( csv_file , csv_fields , lineterminator = '\n' , quoting = csv . QUOTE_NONNUMERIC ) #NEWLINE# csv_writer . writeheader ( ) #NEWLINE# csv_writer . writerow ( csv_data ) #NEWLINE# return csv_file . getvalue ( ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return template . render ( scenario = self . scenario , ** tmpl_vars )