blob: 8fced104f9ecabd23ed29d00bfaa47c75c592c31 [file] [log] [blame]
Per Åhgrenada9b892019-04-03 16:06:42 +02001/*
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
Per Åhgrenada9b892019-04-03 16:06:42 +020014#include <vector>
15
Ali Tofighf3592cb2022-08-16 14:44:38 +020016#include "absl/strings/string_view.h"
17
Per Åhgrenada9b892019-04-03 16:06:42 +020018namespace webrtc {
19namespace test {
20
21// Collects statistics about the API call durations.
22class 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.
Ali Tofighf3592cb2022-08-16 14:44:38 +020033 void WriteReportToFile(absl::string_view filename) const;
Per Åhgrenada9b892019-04-03 16:06:42 +020034
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_