1 // Copyright 2013 The Chromium 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 #ifndef TESTING_PERF_PERF_TEST_H_
6 #define TESTING_PERF_PERF_TEST_H_
7 
8 #include <string>
9 
10 namespace perf_test
11 {
12 
13 // Prints numerical information to stdout in a controlled format, for
14 // post-processing. |measurement| is a description of the quantity being
15 // measured, e.g. "vm_peak"; |modifier| is provided as a convenience and
16 // will be appended directly to the name of the |measurement|, e.g.
17 // "_browser"; |trace| is a description of the particular data point, e.g.
18 // "reference"; |value| is the measured value; and |units| is a description
19 // of the units of measure, e.g. "bytes". If |important| is true, the output
20 // line will be specially marked, to notify the post-processor. The strings
21 // may be empty.  They should not contain any colons (:) or equals signs (=).
22 // A typical post-processing step would be to produce graphs of the data
23 // produced for various builds, using the combined |measurement| + |modifier|
24 // string to specify a particular graph and the |trace| to identify a trace
25 // (i.e., data series) on that graph.
26 void PrintResult(const std::string &measurement,
27                  const std::string &modifier,
28                  const std::string &trace,
29                  size_t value,
30                  const std::string &units,
31                  bool important);
32 void PrintResult(const std::string &measurement,
33                  const std::string &modifier,
34                  const std::string &trace,
35                  double value,
36                  const std::string &units,
37                  bool important);
38 
39 void AppendResult(std::string &output,
40                   const std::string &measurement,
41                   const std::string &modifier,
42                   const std::string &trace,
43                   size_t value,
44                   const std::string &units,
45                   bool important);
46 
47 // Like the above version of PrintResult(), but takes a std::string value
48 // instead of a size_t.
49 void PrintResult(const std::string &measurement,
50                  const std::string &modifier,
51                  const std::string &trace,
52                  const std::string &value,
53                  const std::string &units,
54                  bool important);
55 
56 void AppendResult(std::string &output,
57                   const std::string &measurement,
58                   const std::string &modifier,
59                   const std::string &trace,
60                   const std::string &value,
61                   const std::string &units,
62                   bool important);
63 
64 // Like PrintResult(), but prints a (mean, standard deviation) result pair.
65 // The |<values>| should be two comma-separated numbers, the mean and
66 // standard deviation (or other error metric) of the measurement.
67 void PrintResultMeanAndError(const std::string &measurement,
68                              const std::string &modifier,
69                              const std::string &trace,
70                              const std::string &mean_and_error,
71                              const std::string &units,
72                              bool important);
73 
74 void AppendResultMeanAndError(std::string &output,
75                               const std::string &measurement,
76                               const std::string &modifier,
77                               const std::string &trace,
78                               const std::string &mean_and_error,
79                               const std::string &units,
80                               bool important);
81 
82 // Like PrintResult(), but prints an entire list of results. The |values|
83 // will generally be a list of comma-separated numbers. A typical
84 // post-processing step might produce plots of their mean and standard
85 // deviation.
86 void PrintResultList(const std::string &measurement,
87                      const std::string &modifier,
88                      const std::string &trace,
89                      const std::string &values,
90                      const std::string &units,
91                      bool important);
92 
93 void AppendResultList(std::string &output,
94                       const std::string &measurement,
95                       const std::string &modifier,
96                       const std::string &trace,
97                       const std::string &values,
98                       const std::string &units,
99                       bool important);
100 
101 // Prints memory commit charge stats for use by perf graphs.
102 void PrintSystemCommitCharge(const std::string &test_name, size_t charge, bool important);
103 
104 void PrintSystemCommitCharge(FILE *target,
105                              const std::string &test_name,
106                              size_t charge,
107                              bool important);
108 
109 std::string SystemCommitChargeToString(const std::string &test_name, size_t charge, bool important);
110 
111 }  // namespace perf_test
112 
113 #endif  // TESTING_PERF_PERF_TEST_H_
114