blob: e864bb81436f5908249c4fb163338248d4682cbe [file] [log] [blame]
andrew@webrtc.org2009f6b2012-11-20 00:20:20 +00001/*
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11// A stripped-down version of Chromium's chrome/test/perf/perf_test.h.
12// Several functions have been removed; the prototypes of the remainder have
13// not been changed.
14
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020015#ifndef TEST_TESTSUPPORT_PERF_TEST_H_
16#define TEST_TESTSUPPORT_PERF_TEST_H_
andrew@webrtc.org2009f6b2012-11-20 00:20:20 +000017
danilchap46b89b92016-06-03 09:27:37 -070018#include <sstream>
andrew@webrtc.org2009f6b2012-11-20 00:20:20 +000019#include <string>
20
21namespace webrtc {
22namespace test {
23
24// Prints numerical information to stdout in a controlled format, for
25// post-processing. |measurement| is a description of the quantity being
26// measured, e.g. "vm_peak"; |modifier| is provided as a convenience and
27// will be appended directly to the name of the |measurement|, e.g.
28// "_browser"; |trace| is a description of the particular data point, e.g.
29// "reference"; |value| is the measured value; and |units| is a description
30// of the units of measure, e.g. "bytes". If |important| is true, the output
31// line will be specially marked, to notify the post-processor. The strings
32// may be empty. They should not contain any colons (:) or equals signs (=).
33// A typical post-processing step would be to produce graphs of the data
34// produced for various builds, using the combined |measurement| + |modifier|
35// string to specify a particular graph and the |trace| to identify a trace
36// (i.e., data series) on that graph.
37void PrintResult(const std::string& measurement,
38 const std::string& modifier,
39 const std::string& trace,
40 size_t value,
41 const std::string& units,
42 bool important);
43
andrew@webrtc.org2009f6b2012-11-20 00:20:20 +000044// Like the above version of PrintResult(), but takes a std::string value
45// instead of a size_t.
46void PrintResult(const std::string& measurement,
47 const std::string& modifier,
48 const std::string& trace,
49 const std::string& value,
50 const std::string& units,
51 bool important);
52
andrew@webrtc.org2009f6b2012-11-20 00:20:20 +000053// Like PrintResult(), but prints a (mean, standard deviation) result pair.
54// The |<values>| should be two comma-separated numbers, the mean and
55// standard deviation (or other error metric) of the measurement.
56void PrintResultMeanAndError(const std::string& measurement,
57 const std::string& modifier,
58 const std::string& trace,
59 const std::string& mean_and_error,
60 const std::string& units,
61 bool important);
62
andrew@webrtc.org2009f6b2012-11-20 00:20:20 +000063// Like PrintResult(), but prints an entire list of results. The |values|
64// will generally be a list of comma-separated numbers. A typical
65// post-processing step might produce plots of their mean and standard
66// deviation.
67void PrintResultList(const std::string& measurement,
68 const std::string& modifier,
69 const std::string& trace,
70 const std::string& values,
71 const std::string& units,
72 bool important);
73
danilchap46b89b92016-06-03 09:27:37 -070074// Converts list of values into comma-separated string for PrintResultList.
75template <typename Container>
76std::string ValuesToString(const Container& container) {
77 if (container.empty())
78 return "";
79
80 std::stringstream ss;
81 auto it = container.begin();
82 while (true) {
83 ss << *it;
84 if (++it == container.end())
85 break;
86 ss << ',';
87 }
88 return ss.str();
89}
90
andrew@webrtc.org2009f6b2012-11-20 00:20:20 +000091} // namespace test
92} // namespace webrtc
93
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020094#endif // TEST_TESTSUPPORT_PERF_TEST_H_