aboutsummaryrefslogtreecommitdiff
path: root/deprecated/crb/autotest_gatherer.py
blob: f8f7b43f9fbca3a73251270a4013432457f5c99c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
from table_formatter import TableFormatter as TableFormatter


class AutotestGatherer(TableFormatter):

  def __init__(self):
    self.runs = []
    TableFormatter.__init__(self)

  def GetFormattedMainTable(self, percents_only, fit_string):
    ret = ''
    table = self.GetTableValues()
    ret += self.GetTableLabels(table)
    ret += self.GetFormattedTable(table,
                                  percents_only=percents_only,
                                  fit_string=fit_string)
    return ret

  def GetFormattedSummaryTable(self, percents_only, fit_string):
    ret = ''
    table = self.GetTableValues()
    summary_table = self.GetSummaryTableValues(table)
    ret += self.GetTableLabels(summary_table)
    ret += self.GetFormattedTable(summary_table,
                                  percents_only=percents_only,
                                  fit_string=fit_string)
    return ret

  def GetBenchmarksString(self):
    ret = 'Benchmarks (in order):'
    ret = '\n'.join(self.GetAllBenchmarks())
    return ret

  def GetAllBenchmarks(self):
    all_benchmarks = []
    for run in self.runs:
      for key in run.results.keys():
        if key not in all_benchmarks:
          all_benchmarks.append(key)
    all_benchmarks.sort()
    return all_benchmarks

  def GetTableValues(self):
    table = []
    row = []

    row.append('Benchmark')
    for i in range(len(self.runs)):
      run = self.runs[i]
      label = run.GetLabel()
      label = self.GetLabelWithIteration(label, run.iteration)
      row.append(label)
    table.append(row)

    all_benchmarks = self.GetAllBenchmarks()
    for benchmark in all_benchmarks:
      row = []
      row.append(benchmark)
      for run in self.runs:
        results = run.results
        if benchmark in results:
          row.append(results[benchmark])
        else:
          row.append('')
      table.append(row)

    return table