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