andrew@webrtc.org | 2009f6b | 2012-11-20 00:20:20 +0000 | [diff] [blame] | 1 | /* |
| 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 Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 15 | #ifndef TEST_TESTSUPPORT_PERF_TEST_H_ |
| 16 | #define TEST_TESTSUPPORT_PERF_TEST_H_ |
andrew@webrtc.org | 2009f6b | 2012-11-20 00:20:20 +0000 | [diff] [blame] | 17 | |
danilchap | 46b89b9 | 2016-06-03 09:27:37 -0700 | [diff] [blame] | 18 | #include <sstream> |
andrew@webrtc.org | 2009f6b | 2012-11-20 00:20:20 +0000 | [diff] [blame] | 19 | #include <string> |
| 20 | |
| 21 | namespace webrtc { |
| 22 | namespace 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. |
| 37 | void PrintResult(const std::string& measurement, |
| 38 | const std::string& modifier, |
| 39 | const std::string& trace, |
Edward Lemur | 6a82207 | 2017-11-22 19:17:50 +0100 | [diff] [blame] | 40 | const double value, |
andrew@webrtc.org | 2009f6b | 2012-11-20 00:20:20 +0000 | [diff] [blame] | 41 | const std::string& units, |
| 42 | bool important); |
| 43 | |
andrew@webrtc.org | 2009f6b | 2012-11-20 00:20:20 +0000 | [diff] [blame] | 44 | // Like PrintResult(), but prints a (mean, standard deviation) result pair. |
| 45 | // The |<values>| should be two comma-separated numbers, the mean and |
| 46 | // standard deviation (or other error metric) of the measurement. |
| 47 | void PrintResultMeanAndError(const std::string& measurement, |
| 48 | const std::string& modifier, |
| 49 | const std::string& trace, |
| 50 | const std::string& mean_and_error, |
| 51 | const std::string& units, |
| 52 | bool important); |
| 53 | |
andrew@webrtc.org | 2009f6b | 2012-11-20 00:20:20 +0000 | [diff] [blame] | 54 | // Like PrintResult(), but prints an entire list of results. The |values| |
| 55 | // will generally be a list of comma-separated numbers. A typical |
| 56 | // post-processing step might produce plots of their mean and standard |
| 57 | // deviation. |
| 58 | void PrintResultList(const std::string& measurement, |
| 59 | const std::string& modifier, |
| 60 | const std::string& trace, |
| 61 | const std::string& values, |
| 62 | const std::string& units, |
| 63 | bool important); |
| 64 | |
danilchap | 46b89b9 | 2016-06-03 09:27:37 -0700 | [diff] [blame] | 65 | // Converts list of values into comma-separated string for PrintResultList. |
| 66 | template <typename Container> |
| 67 | std::string ValuesToString(const Container& container) { |
| 68 | if (container.empty()) |
| 69 | return ""; |
| 70 | |
| 71 | std::stringstream ss; |
| 72 | auto it = container.begin(); |
| 73 | while (true) { |
| 74 | ss << *it; |
| 75 | if (++it == container.end()) |
| 76 | break; |
| 77 | ss << ','; |
| 78 | } |
| 79 | return ss.str(); |
| 80 | } |
| 81 | |
andrew@webrtc.org | 2009f6b | 2012-11-20 00:20:20 +0000 | [diff] [blame] | 82 | } // namespace test |
| 83 | } // namespace webrtc |
| 84 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 85 | #endif // TEST_TESTSUPPORT_PERF_TEST_H_ |