parameters: (json1, json2, use_color=True)
return_statement: return output_strs
docstring: Calculate and report the difference between each test of two benchmarks
      runs specified as 'json1' and 'json2'.
docstring_summary: Calculate and report the difference between each test of two benchmarks
      runs specified as 'json1' and 'json2'.
docstring_tokens: Calculate and report the difference between each test of two benchmarks runs specified as json1 and json2 .
function: def generate_difference_report(json1, json2, use_color=True):
      """
      Calculate and report the difference between each test of two benchmarks
      runs specified as 'json1' and 'json2'.
      """
      first_col_width = find_longest_name(json1['benchmarks'])
      def find_test(name):
          for b in json2['benchmarks']:
              if b['name'] == name:
                  return b
          return None
      first_col_width = max(first_col_width, len('Benchmark'))
      first_line = "{:<{}s}Time             CPU      Time Old      Time New       CPU Old       CPU New".format(
          'Benchmark', 12 + first_col_width)
      output_strs = [first_line, '-' * len(first_line)]
  
      gen = (bn for bn in json1['benchmarks'] if 'real_time' in bn and 'cpu_time' in bn)
      for bn in gen:
          other_bench = find_test(bn['name'])
          if not other_bench:
              continue
  
          if bn['time_unit'] != other_bench['time_unit']:
              continue
  
          def get_color(res):
              if res > 0.05:
                  return BC_FAIL
              elif res > -0.07:
                  return BC_WHITE
              else:
                  return BC_CYAN
          fmt_str = "{}{:<{}s}{endc}{}{:+16.4f}{endc}{}{:+16.4f}{endc}{:14.0f}{:14.0f}{endc}{:14.0f}{:14.0f}"
          tres = calculate_change(bn['real_time'], other_bench['real_time'])
          cpures = calculate_change(bn['cpu_time'], other_bench['cpu_time'])
          output_strs += [color_format(use_color, fmt_str,
              BC_HEADER, bn['name'], first_col_width,
              get_color(tres), tres, get_color(cpures), cpures,
              bn['real_time'], other_bench['real_time'],
              bn['cpu_time'], other_bench['cpu_time'],
              endc=BC_ENDC)]
      return output_strs
function_tokens: def generate_difference_report ( json1 , json2 , use_color = True ) : first_col_width = find_longest_name ( json1 [ 'benchmarks' ] ) def find_test ( name ) : for b in json2 [ 'benchmarks' ] : if b [ 'name' ] == name : return b return None first_col_width = max ( first_col_width , len ( 'Benchmark' ) ) first_line = "{:<{}s}Time             CPU      Time Old      Time New       CPU Old       CPU New" . format ( 'Benchmark' , 12 + first_col_width ) output_strs = [ first_line , '-' * len ( first_line ) ] gen = ( bn for bn in json1 [ 'benchmarks' ] if 'real_time' in bn and 'cpu_time' in bn ) for bn in gen : other_bench = find_test ( bn [ 'name' ] ) if not other_bench : continue if bn [ 'time_unit' ] != other_bench [ 'time_unit' ] : continue def get_color ( res ) : if res > 0.05 : return BC_FAIL elif res > - 0.07 : return BC_WHITE else : return BC_CYAN fmt_str = "{}{:<{}s}{endc}{}{:+16.4f}{endc}{}{:+16.4f}{endc}{:14.0f}{:14.0f}{endc}{:14.0f}{:14.0f}" tres = calculate_change ( bn [ 'real_time' ] , other_bench [ 'real_time' ] ) cpures = calculate_change ( bn [ 'cpu_time' ] , other_bench [ 'cpu_time' ] ) output_strs += [ color_format ( use_color , fmt_str , BC_HEADER , bn [ 'name' ] , first_col_width , get_color ( tres ) , tres , get_color ( cpures ) , cpures , bn [ 'real_time' ] , other_bench [ 'real_time' ] , bn [ 'cpu_time' ] , other_bench [ 'cpu_time' ] , endc = BC_ENDC ) ] return output_strs