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 11 #ifndef MODULES_AUDIO_PROCESSING_TEST_API_CALL_STATISTICS_H_ 12 #define MODULES_AUDIO_PROCESSING_TEST_API_CALL_STATISTICS_H_ 13 14 #include <vector> 15 16 #include "absl/strings/string_view.h" 17 18 namespace webrtc { 19 namespace test { 20 21 // Collects statistics about the API call durations. 22 class ApiCallStatistics { 23 public: 24 enum class CallType { kRender, kCapture }; 25 26 // Adds a new datapoint. 27 void Add(int64_t duration_nanos, CallType call_type); 28 29 // Prints out a report of the statistics. 30 void PrintReport() const; 31 32 // Writes the call information to a file. 33 void WriteReportToFile(absl::string_view filename) const; 34 35 private: 36 struct CallData { 37 CallData(int64_t duration_nanos, CallType call_type); 38 int64_t duration_nanos; 39 CallType call_type; 40 }; 41 std::vector<CallData> calls_; 42 }; 43 44 } // namespace test 45 } // namespace webrtc 46 47 #endif // MODULES_AUDIO_PROCESSING_TEST_API_CALL_STATISTICS_H_ 48