Home | History | Annotate | Download | only in crb
      1 from table_formatter import TableFormatter as TableFormatter
      2 
      3 
      4 class AutotestGatherer(TableFormatter):
      5 
      6   def __init__(self):
      7     self.runs = []
      8     TableFormatter.__init__(self)
      9 
     10   def GetFormattedMainTable(self, percents_only, fit_string):
     11     ret = ''
     12     table = self.GetTableValues()
     13     ret += self.GetTableLabels(table)
     14     ret += self.GetFormattedTable(table,
     15                                   percents_only=percents_only,
     16                                   fit_string=fit_string)
     17     return ret
     18 
     19   def GetFormattedSummaryTable(self, percents_only, fit_string):
     20     ret = ''
     21     table = self.GetTableValues()
     22     summary_table = self.GetSummaryTableValues(table)
     23     ret += self.GetTableLabels(summary_table)
     24     ret += self.GetFormattedTable(summary_table,
     25                                   percents_only=percents_only,
     26                                   fit_string=fit_string)
     27     return ret
     28 
     29   def GetBenchmarksString(self):
     30     ret = 'Benchmarks (in order):'
     31     ret = '\n'.join(self.GetAllBenchmarks())
     32     return ret
     33 
     34   def GetAllBenchmarks(self):
     35     all_benchmarks = []
     36     for run in self.runs:
     37       for key in run.results.keys():
     38         if key not in all_benchmarks:
     39           all_benchmarks.append(key)
     40     all_benchmarks.sort()
     41     return all_benchmarks
     42 
     43   def GetTableValues(self):
     44     table = []
     45     row = []
     46 
     47     row.append('Benchmark')
     48     for i in range(len(self.runs)):
     49       run = self.runs[i]
     50       label = run.GetLabel()
     51       label = self.GetLabelWithIteration(label, run.iteration)
     52       row.append(label)
     53     table.append(row)
     54 
     55     all_benchmarks = self.GetAllBenchmarks()
     56     for benchmark in all_benchmarks:
     57       row = []
     58       row.append(benchmark)
     59       for run in self.runs:
     60         results = run.results
     61         if benchmark in results:
     62           row.append(results[benchmark])
     63         else:
     64           row.append('')
     65       table.append(row)
     66 
     67     return table
     68