api_call_statistics.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /*
  2. * Copyright (c) 2019 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 MODULES_AUDIO_PROCESSING_TEST_API_CALL_STATISTICS_H_
  11. #define MODULES_AUDIO_PROCESSING_TEST_API_CALL_STATISTICS_H_
  12. #include <string>
  13. #include <vector>
  14. namespace webrtc {
  15. namespace test {
  16. // Collects statistics about the API call durations.
  17. class ApiCallStatistics {
  18. public:
  19. enum class CallType { kRender, kCapture };
  20. // Adds a new datapoint.
  21. void Add(int64_t duration_nanos, CallType call_type);
  22. // Prints out a report of the statistics.
  23. void PrintReport() const;
  24. // Writes the call information to a file.
  25. void WriteReportToFile(const std::string& filename) const;
  26. private:
  27. struct CallData {
  28. CallData(int64_t duration_nanos, CallType call_type);
  29. int64_t duration_nanos;
  30. CallType call_type;
  31. };
  32. std::vector<CallData> calls_;
  33. };
  34. } // namespace test
  35. } // namespace webrtc
  36. #endif // MODULES_AUDIO_PROCESSING_TEST_API_CALL_STATISTICS_H_