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

Side by Side Diff: chrome/test/perf/perf_test.cc

Issue 23509002: Factor out a perf test result printer method. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix mac compile Created 7 years, 3 months 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 | « chrome/test/perf/perf_test.h ('k') | chrome/test/perf/rendering/throughput_tests.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/test/perf/perf_test.h" 5 #include "chrome/test/perf/perf_test.h"
6 6
7 #include <stdio.h> 7 #include <stdio.h>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
11 #include "base/strings/stringprintf.h" 11 #include "base/strings/stringprintf.h"
12 #include "chrome/test/base/chrome_process_util.h" 12 #include "chrome/test/base/chrome_process_util.h"
13 13 #include "testing/perf/perf_test.h"
14 namespace {
15
16 std::string ResultsToString(const std::string& measurement,
17 const std::string& modifier,
18 const std::string& trace,
19 const std::string& values,
20 const std::string& prefix,
21 const std::string& suffix,
22 const std::string& units,
23 bool important) {
24 // <*>RESULT <graph_name>: <trace_name>= <value> <units>
25 // <*>RESULT <graph_name>: <trace_name>= {<mean>, <std deviation>} <units>
26 // <*>RESULT <graph_name>: <trace_name>= [<value>,value,value,...,] <units>
27 return base::StringPrintf("%sRESULT %s%s: %s= %s%s%s %s\n",
28 important ? "*" : "", measurement.c_str(), modifier.c_str(),
29 trace.c_str(), prefix.c_str(), values.c_str(), suffix.c_str(),
30 units.c_str());
31 }
32
33 void PrintResultsImpl(const std::string& measurement,
34 const std::string& modifier,
35 const std::string& trace,
36 const std::string& values,
37 const std::string& prefix,
38 const std::string& suffix,
39 const std::string& units,
40 bool important) {
41 fflush(stdout);
42 printf("%s", ResultsToString(measurement, modifier, trace, values,
43 prefix, suffix, units, important).c_str());
44 fflush(stdout);
45 }
46
47 } // namespace
48 14
49 namespace perf_test { 15 namespace perf_test {
50 16
51 void PrintResult(const std::string& measurement,
52 const std::string& modifier,
53 const std::string& trace,
54 size_t value,
55 const std::string& units,
56 bool important) {
57 PrintResultsImpl(measurement,
58 modifier,
59 trace,
60 base::UintToString(value),
61 std::string(),
62 std::string(),
63 units,
64 important);
65 }
66
67 void AppendResult(std::string& output,
68 const std::string& measurement,
69 const std::string& modifier,
70 const std::string& trace,
71 size_t value,
72 const std::string& units,
73 bool important) {
74 output += ResultsToString(measurement,
75 modifier,
76 trace,
77 base::UintToString(value),
78 std::string(),
79 std::string(),
80 units,
81 important);
82 }
83
84 void PrintResult(const std::string& measurement,
85 const std::string& modifier,
86 const std::string& trace,
87 const std::string& value,
88 const std::string& units,
89 bool important) {
90 PrintResultsImpl(measurement,
91 modifier,
92 trace,
93 value,
94 std::string(),
95 std::string(),
96 units,
97 important);
98 }
99
100 void AppendResult(std::string& output,
101 const std::string& measurement,
102 const std::string& modifier,
103 const std::string& trace,
104 const std::string& value,
105 const std::string& units,
106 bool important) {
107 output += ResultsToString(measurement,
108 modifier,
109 trace,
110 value,
111 std::string(),
112 std::string(),
113 units,
114 important);
115 }
116
117 void PrintResultMeanAndError(const std::string& measurement,
118 const std::string& modifier,
119 const std::string& trace,
120 const std::string& mean_and_error,
121 const std::string& units,
122 bool important) {
123 PrintResultsImpl(measurement, modifier, trace, mean_and_error,
124 "{", "}", units, important);
125 }
126
127 void AppendResultMeanAndError(std::string& output,
128 const std::string& measurement,
129 const std::string& modifier,
130 const std::string& trace,
131 const std::string& mean_and_error,
132 const std::string& units,
133 bool important) {
134 output += ResultsToString(measurement, modifier, trace, mean_and_error,
135 "{", "}", units, important);
136 }
137
138 void PrintResultList(const std::string& measurement,
139 const std::string& modifier,
140 const std::string& trace,
141 const std::string& values,
142 const std::string& units,
143 bool important) {
144 PrintResultsImpl(measurement, modifier, trace, values,
145 "[", "]", units, important);
146 }
147
148 void AppendResultList(std::string& output,
149 const std::string& measurement,
150 const std::string& modifier,
151 const std::string& trace,
152 const std::string& values,
153 const std::string& units,
154 bool important) {
155 output += ResultsToString(measurement, modifier, trace, values,
156 "[", "]", units, important);
157 }
158
159 void PrintIOPerfInfo(const std::string& test_name, 17 void PrintIOPerfInfo(const std::string& test_name,
160 const ChromeProcessList& chrome_processes, 18 const ChromeProcessList& chrome_processes,
161 base::ProcessId browser_pid) { 19 base::ProcessId browser_pid) {
162 PrintIOPerfInfo(stdout, test_name, chrome_processes, browser_pid); 20 PrintIOPerfInfo(stdout, test_name, chrome_processes, browser_pid);
163 } 21 }
164 22
165 void PrintIOPerfInfo(FILE* target, 23 void PrintIOPerfInfo(FILE* target,
166 const std::string& test_name, 24 const std::string& test_name,
167 const ChromeProcessList& chrome_processes, 25 const ChromeProcessList& chrome_processes,
168 base::ProcessId browser_pid) { 26 base::ProcessId browser_pid) {
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after
544 "processes", 402 "processes",
545 std::string(), 403 std::string(),
546 "proc_" + trace_name, 404 "proc_" + trace_name,
547 chrome_processes.size(), 405 chrome_processes.size(),
548 "count", 406 "count",
549 false /* not important */); 407 false /* not important */);
550 408
551 return output; 409 return output;
552 } 410 }
553 411
554 void PrintSystemCommitCharge(const std::string& test_name,
555 size_t charge,
556 bool important) {
557 PrintSystemCommitCharge(stdout, test_name, charge, important);
558 }
559
560 void PrintSystemCommitCharge(FILE* target,
561 const std::string& test_name,
562 size_t charge,
563 bool important) {
564 fprintf(target, "%s", SystemCommitChargeToString(test_name, charge,
565 important).c_str());
566 }
567
568 std::string SystemCommitChargeToString(const std::string& test_name,
569 size_t charge,
570 bool important) {
571 std::string trace_name(test_name);
572 std::string output;
573 AppendResult(output,
574 "commit_charge",
575 std::string(),
576 "cc" + trace_name,
577 charge,
578 "kb",
579 important);
580 return output;
581 }
582
583 } // namespace perf_test 412 } // namespace perf_test
OLDNEW
« no previous file with comments | « chrome/test/perf/perf_test.h ('k') | chrome/test/perf/rendering/throughput_tests.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698