#NEWLINE# def _CreateSamples( ycsb_result , include_histogram = True , **kwargs ) : #NEWLINE# #INDENT# 'Create PKB samples from a YCSB result.\n\n  Args:\n    ycsb_result: dict. Result of ParseResults.\n    include_histogram: bool. If True, include records for each histogram bin.\n    **kwargs: Base metadata for each sample.\n\n  Returns:\n    List of sample.Sample objects.\n  ' #NEWLINE# stage = ( 'load' if ycsb_result [ 'command_line' ] . endswith ( '-load' ) else 'run' ) #NEWLINE# base_metadata = { #NEWLINE# #INDENT# 'command_line' : ycsb_result [ 'command_line' ] , #NEWLINE# 'stage' : stage , #NEWLINE# #UNINDENT# } #NEWLINE# base_metadata . update ( kwargs ) #NEWLINE# for ( group_name , group ) in ycsb_result [ 'groups' ] . iteritems ( ) : #NEWLINE# #INDENT# meta = base_metadata . copy ( ) #NEWLINE# meta [ 'operation' ] = group_name #NEWLINE# for ( statistic , value ) in group [ 'statistics' ] . iteritems ( ) : #NEWLINE# #INDENT# if ( value is None ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# unit = '' #NEWLINE# m = re . match ( '^(.*) *\\((us|ms|ops/sec)\\)$' , statistic ) #NEWLINE# if m : #NEWLINE# #INDENT# statistic = m . group ( 1 ) #NEWLINE# unit = m . group ( 2 ) #NEWLINE# #UNINDENT# ( yield sample . Sample ( ' ' . join ( [ group_name , statistic ] ) , value , unit , meta ) ) #NEWLINE# #UNINDENT# if group [ 'histogram' ] : #NEWLINE# #INDENT# percentiles = _PercentilesFromHistogram ( group [ 'histogram' ] ) #NEWLINE# for ( label , value ) in percentiles . iteritems ( ) : #NEWLINE# #INDENT# ( yield sample . Sample ( ' ' . join ( [ group_name , label , 'latency' ] ) , value , 'ms' , meta ) ) #NEWLINE# #UNINDENT# #UNINDENT# if include_histogram : #NEWLINE# #INDENT# for ( time_ms , count ) in group [ 'histogram' ] : #NEWLINE# #INDENT# ( yield sample . Sample ( '{0}_latency_histogram_{1}_ms' . format ( group_name , time_ms ) , count , 'count' , meta ) )