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