Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(200)

Side by Side Diff: bootperf-bin/perfprinter.py

Issue 4148011: Create bootperf-bin tools for running boot time tests and reporting results (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/crosutils.git
Patch Set: Apply selected fixes recommended by gpylint Created 10 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « bootperf-bin/bootperf ('k') | bootperf-bin/resultset.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4
5 """Routines for printing boot time performance test results."""
6
7 import fnmatch
8 import os
9 import os.path
10 import re
11
12 import resultset
13
14
15 _PERF_KEYVAL_PATTERN = re.compile("(.*){perf}=(.*)\n")
16
17
18 def ReadKeyvalFile(results, file_):
19 """Read an autotest keyval file, and process the results.
20
21 The `file_` parameter is a file object with contents in autotest
22 perf keyval format:
23 <keyname>{perf}=<value>
24
25 Each iteration of the test is terminated with a single blank line,
26 including the last iteration. Each iteration's results are added
27 to the `results` parameter, which should be an instance of
28 TestResultSet.
29
30 """
31 kvd = {}
32 for line in iter(file_):
33 if line == "\n":
34 results.AddIterationResults(kvd)
35 kvd = {}
36 continue
37 m = _PERF_KEYVAL_PATTERN.match(line)
38 if m is None:
39 continue
40 kvd[m.group(1)] = m.group(2)
41
42
43 _RESULTS_PATH = (
44 "summary/platform_BootPerfServer/platform_BootPerfServer/results/keyval")
45
46
47 def ReadResultsDirectory(dir_):
48 """Process results from a 'bootperf' output directory.
49
50 The accumulated results are returned in a newly created
51 TestResultSet object.
52
53 """
54 res_set = resultset.TestResultSet(dir_)
55 dirlist = fnmatch.filter(os.listdir(dir_), "run.???")
56 dirlist.sort()
57 for run in dirlist:
58 keyval_path = os.path.join(dir_, run, _RESULTS_PATH)
59 try:
60 kvf = open(keyval_path)
61 except IOError:
62 continue
63 ReadKeyvalFile(res_set, kvf)
64 res_set.FinalizeResults()
65 return res_set
66
67
68 def PrintRawData(dirlist, use_timestats, keylist):
69 """Print 'bootperf' results in "raw data" format."""
70 for dir_ in dirlist:
71 if use_timestats:
72 keyset = ReadResultsDirectory(dir_).TimeKeySet()
73 else:
74 keyset = ReadResultsDirectory(dir_).DiskKeySet()
75 for i in range(0, keyset.num_iterations):
76 if len(dirlist) > 1:
77 line = "%s %3d" % (dir_, i)
78 else:
79 line = "%3d" % i
80 if keylist is not None:
81 markers = keylist
82 else:
83 markers = keyset.markers
84 for stat in markers:
85 (_, v) = keyset.PrintableStatistic(keyset.RawData(stat)[i])
86 line += " %5s" % str(v)
87 print line
88
89
90 def PrintStatisticsSummary(dirlist, use_timestats, keylist):
91 """Print 'bootperf' results in "summary of averages" format."""
92 if use_timestats:
93 header = "%5s %3s %5s %3s %s" % (
94 "time", "s%", "dt", "s%", "event")
95 format = "%5s %2d%% %5s %2d%% %s"
96 else:
97 header = "%6s %3s %6s %3s %s" % (
98 "diskrd", "s%", "delta", "s%", "event")
99 format = "%6s %2d%% %6s %2d%% %s"
100 havedata = False
101 for dir_ in dirlist:
102 if use_timestats:
103 keyset = ReadResultsDirectory(dir_).TimeKeySet()
104 else:
105 keyset = ReadResultsDirectory(dir_).DiskKeySet()
106 if keylist is not None:
107 markers = keylist
108 else:
109 markers = keyset.markers
110 if havedata:
111 print
112 if len(dirlist) > 1:
113 print "%s" % dir_,
114 print "(on %d cycles):" % keyset.num_iterations
115 print header
116 prevvalue = 0
117 prevstat = None
118 for stat in markers:
119 (valueavg, valuedev) = keyset.Statistics(stat)
120 valuepct = int(100 * valuedev / valueavg + 0.5)
121 if prevstat:
122 (deltaavg, deltadev) = keyset.DeltaStatistics(prevstat, stat)
123 deltapct = int(100 * deltadev / deltaavg + 0.5)
124 else:
125 deltapct = valuepct
126 (valstring, val_printed) = keyset.PrintableStatistic(valueavg)
127 delta = val_printed - prevvalue
128 (deltastring, _) = keyset.PrintableStatistic(delta)
129 print format % (valstring, valuepct, "+" + deltastring, deltapct, stat)
130 prevvalue = val_printed
131 prevstat = stat
132 havedata = True
OLDNEW
« no previous file with comments | « bootperf-bin/bootperf ('k') | bootperf-bin/resultset.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698