parameters: (self, show_averages=False, percentage=ABS_PERCENTAGE_NO_HIGHLIGHT, be_quiet=False, markdown=False, colorize=False)
docstring: Generate the comparison output.
docstring_summary: Generate the comparison output.
docstring_tokens: Generate the comparison output .
function: def output(self, show_averages=False, percentage=ABS_PERCENTAGE_NO_HIGHLIGHT, be_quiet=False, markdown=False, colorize=False):
          """Generate the comparison output."""
          benches_in_both = self._common_benches()
          if not benches_in_both:
              logging.warning("Warning: The files have no benchmarks in common - nothing to compare!")
              return
  
          color_on = 1 if colorize else 0
          if not be_quiet:
              only_in_before = self._benches_only_in_before_file()
              if only_in_before:
                  logging.warning(
                      "Warning: Unable to compare some benchmarks existing only in 'before' file:\n{}{}{}\n".format(
                          YELLOW[color_on], '\n'.join(
                              sorted(only_in_before)), YELLOW[0]))
  
              only_in_after = self._benches_only_in_after_file()
              if only_in_after:
                  logging.warning(
                      "Warning: Unable to compare some benchmarks existing only in 'after' file:\n{}{}{}\n".format(
                          YELLOW[color_on], '\n'.join(
                              sorted(only_in_after)), YELLOW[0]))
  
          # Output the header
          if markdown:
              # markdown table header
              header_row = "| Benchmark | median_before | median_after | median_pct_change"
              if show_averages:
                  header_row += " | avg_before | avg_after | avg_pct_change"
              header_row += " |"
              print(header_row)
              # separator line
              num_vert_bars = header_row.count('|')
              print('|' + '|'.join(["---", ] * (num_vert_bars - 1)) + '|')
          else:
              header_row = "# Benchmark,median_before,median_after,median_pct_change"
              if show_averages:
                  header_row += ",avg_before,avg_after,avg_pct_change"
              print(header_row)
  
          # Output the rows
          for cb in sorted(benches_in_both):
              # Construct a list of elements in the row
              # Starting with the benchmark name...
              output_row_elems = [cb, ]
  
              median_before = self.before_file_obj[cb].t_median
              median_after = self.after_file_obj[cb].t_median
              median_pct_change = 100 * (median_after - median_before) / median_before
              output_row_elems += [median_before, median_after, median_pct_change]
  
              avg_before = self.before_file_obj[cb].t_avg
              avg_after = self.after_file_obj[cb].t_avg
              avg_pct_change = 100 * (avg_after - avg_before) / avg_before
  
              if show_averages:
                  output_row_elems += [avg_before, avg_after, avg_pct_change]
  
              if markdown:
                  # markdown row output
                  row_str = "|" + " | ".join([str(x) for x in output_row_elems[0:3]])
                  # median_pct_change
                  row_str += ' | ' + "{:.2f}".format(output_row_elems[3])
                  if show_averages:
                      # avg_before, avg_after
                      row_str += ' | ' + " | ".join([str(x) for x in output_row_elems[4:6]])
                      # avg_pct_change
                      row_str += ' | ' + "{:.2f}".format(output_row_elems[6])
  
                  print(row_str.strip() + ' |')
              else:
                  # plain text row output
                  # name, median_before, median_after
                  row_str = ",".join([str(x) for x in output_row_elems[0:3]])
                  color_on_str = ''
                  color_off_str = ''
                  if colorize:
                      if abs(median_pct_change) > float(percentage) or abs(avg_pct_change) > float(percentage):
                          color_on_str, color_off_str = (
                              RED[color_on], RED[0]) if median_pct_change > 0.0 else (
                              GREEN[color_on], GREEN[0])
                  # median_pct_change
                  row_str += ',' + color_on_str + "{:.2f}".format(output_row_elems[3]) + color_off_str
                  if show_averages:
                      # avg_before, avg_after
                      row_str += ',' + ",".join([str(x) for x in output_row_elems[4:6]])
                      # avg_pct_change
                      row_str += ',' + color_on_str + "{:.2f}".format(output_row_elems[6]) + color_off_str
  
                  print(row_str)
function_tokens: def output ( self , show_averages = False , percentage = ABS_PERCENTAGE_NO_HIGHLIGHT , be_quiet = False , markdown = False , colorize = False ) : benches_in_both = self . _common_benches ( ) if not benches_in_both : logging . warning ( "Warning: The files have no benchmarks in common - nothing to compare!" ) return color_on = 1 if colorize else 0 if not be_quiet : only_in_before = self . _benches_only_in_before_file ( ) if only_in_before : logging . warning ( "Warning: Unable to compare some benchmarks existing only in 'before' file:\n{}{}{}\n" . format ( YELLOW [ color_on ] , '\n' . join ( sorted ( only_in_before ) ) , YELLOW [ 0 ] ) ) only_in_after = self . _benches_only_in_after_file ( ) if only_in_after : logging . warning ( "Warning: Unable to compare some benchmarks existing only in 'after' file:\n{}{}{}\n" . format ( YELLOW [ color_on ] , '\n' . join ( sorted ( only_in_after ) ) , YELLOW [ 0 ] ) ) # Output the header if markdown : # markdown table header header_row = "| Benchmark | median_before | median_after | median_pct_change" if show_averages : header_row += " | avg_before | avg_after | avg_pct_change" header_row += " |" print ( header_row ) # separator line num_vert_bars = header_row . count ( '|' ) print ( '|' + '|' . join ( [ "---" , ] * ( num_vert_bars - 1 ) ) + '|' ) else : header_row = "# Benchmark,median_before,median_after,median_pct_change" if show_averages : header_row += ",avg_before,avg_after,avg_pct_change" print ( header_row ) # Output the rows for cb in sorted ( benches_in_both ) : # Construct a list of elements in the row # Starting with the benchmark name... output_row_elems = [ cb , ] median_before = self . before_file_obj [ cb ] . t_median median_after = self . after_file_obj [ cb ] . t_median median_pct_change = 100 * ( median_after - median_before ) / median_before output_row_elems += [ median_before , median_after , median_pct_change ] avg_before = self . before_file_obj [ cb ] . t_avg avg_after = self . after_file_obj [ cb ] . t_avg avg_pct_change = 100 * ( avg_after - avg_before ) / avg_before if show_averages : output_row_elems += [ avg_before , avg_after , avg_pct_change ] if markdown : # markdown row output row_str = "|" + " | " . join ( [ str ( x ) for x in output_row_elems [ 0 : 3 ] ] ) # median_pct_change row_str += ' | ' + "{:.2f}" . format ( output_row_elems [ 3 ] ) if show_averages : # avg_before, avg_after row_str += ' | ' + " | " . join ( [ str ( x ) for x in output_row_elems [ 4 : 6 ] ] ) # avg_pct_change row_str += ' | ' + "{:.2f}" . format ( output_row_elems [ 6 ] ) print ( row_str . strip ( ) + ' |' ) else : # plain text row output # name, median_before, median_after row_str = "," . join ( [ str ( x ) for x in output_row_elems [ 0 : 3 ] ] ) color_on_str = '' color_off_str = '' if colorize : if abs ( median_pct_change ) > float ( percentage ) or abs ( avg_pct_change ) > float ( percentage ) : color_on_str , color_off_str = ( RED [ color_on ] , RED [ 0 ] ) if median_pct_change > 0.0 else ( GREEN [ color_on ] , GREEN [ 0 ] ) # median_pct_change row_str += ',' + color_on_str + "{:.2f}" . format ( output_row_elems [ 3 ] ) + color_off_str if show_averages : # avg_before, avg_after row_str += ',' + "," . join ( [ str ( x ) for x in output_row_elems [ 4 : 6 ] ] ) # avg_pct_change row_str += ',' + color_on_str + "{:.2f}" . format ( output_row_elems [ 6 ] ) + color_off_str print ( row_str )