perf_test.h 5.0 KB

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