You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

115 lines
4.6 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  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. #ifndef TEST_TESTSUPPORT_PERF_TEST_H_
  11. #define TEST_TESTSUPPORT_PERF_TEST_H_
  12. #include <sstream>
  13. #include <string>
  14. #include <vector>
  15. #include "api/array_view.h"
  16. #include "rtc_base/numerics/samples_stats_counter.h"
  17. namespace webrtc {
  18. namespace test {
  19. // Metrics improver direction.
  20. enum class ImproveDirection {
  21. // Direction is undefined.
  22. kNone,
  23. // Smaller value is better.
  24. kSmallerIsBetter,
  25. // Bigger value is better.
  26. kBiggerIsBetter,
  27. };
  28. // Prints numerical information to stdout in a controlled format, for
  29. // post-processing. |measurement| is a description of the quantity being
  30. // measured, e.g. "vm_peak"; |modifier| is provided as a convenience and
  31. // will be appended directly to the name of the |measurement|, e.g.
  32. // "_browser"; |trace| is a description of the particular data point, e.g.
  33. // "reference"; |value| is the measured value; and |units| is a description
  34. // of the units of measure, e.g. "bytes". If |important| is true, the output
  35. // line will be specially marked, to notify the post-processor. The strings
  36. // may be empty. They should not contain any colons (:) or equals signs (=).
  37. // A typical post-processing step would be to produce graphs of the data
  38. // produced for various builds, using the combined |measurement| + |modifier|
  39. // string to specify a particular graph and the |trace| to identify a trace
  40. // (i.e., data series) on that graph.
  41. void PrintResult(const std::string& measurement,
  42. const std::string& modifier,
  43. const std::string& trace,
  44. const double value,
  45. const std::string& units,
  46. bool important,
  47. ImproveDirection improve_direction = ImproveDirection::kNone);
  48. // Like PrintResult(), but prints a (mean, standard deviation) result pair.
  49. // The |<values>| should be two comma-separated numbers, the mean and
  50. // standard deviation (or other error metric) of the measurement.
  51. void PrintResultMeanAndError(
  52. const std::string& measurement,
  53. const std::string& modifier,
  54. const std::string& trace,
  55. const double mean,
  56. const double error,
  57. const std::string& units,
  58. bool important,
  59. ImproveDirection improve_direction = ImproveDirection::kNone);
  60. // Like PrintResult(), but prints an entire list of results. The |values|
  61. // will generally be a list of comma-separated numbers. A typical
  62. // post-processing step might produce plots of their mean and standard
  63. // deviation.
  64. void PrintResultList(
  65. const std::string& measurement,
  66. const std::string& modifier,
  67. const std::string& trace,
  68. rtc::ArrayView<const double> values,
  69. const std::string& units,
  70. bool important,
  71. ImproveDirection improve_direction = ImproveDirection::kNone);
  72. // Like PrintResult(), but prints a (mean, standard deviation) from stats
  73. // counter. Also add specified metric to the plotable metrics output.
  74. void PrintResult(const std::string& measurement,
  75. const std::string& modifier,
  76. const std::string& trace,
  77. const SamplesStatsCounter& counter,
  78. const std::string& units,
  79. const bool important,
  80. ImproveDirection improve_direction = ImproveDirection::kNone);
  81. // Returns all perf results to date in a JSON string formatted as described in
  82. // https://github.com/catapult-project/catapult/blob/master/dashboard/docs/data-format.md
  83. std::string GetPerfResultsJSON();
  84. // Print into stdout plottable metrics for further post processing.
  85. // |desired_graphs| - list of metrics, that should be plotted. If empty - all
  86. // available metrics will be plotted. If some of |desired_graphs| are missing
  87. // they will be skipped.
  88. void PrintPlottableResults(const std::vector<std::string>& desired_graphs);
  89. // Writes the JSON representation of the perf results returned by
  90. // GetPerfResultsJSON() to the file in output_path.
  91. void WritePerfResults(const std::string& output_path);
  92. // By default, perf results are printed to stdout. Set the FILE* to where they
  93. // should be printing instead.
  94. void SetPerfResultsOutput(FILE* output);
  95. // You shouldn't use this function. It's only used to test the functions above.
  96. void ClearPerfResults();
  97. } // namespace test
  98. } // namespace webrtc
  99. #endif // TEST_TESTSUPPORT_PERF_TEST_H_