performance_timer.h (1430B)
1 /* 2 * Copyright (c) 2016 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_PERFORMANCE_TIMER_H_ 12 #define MODULES_AUDIO_PROCESSING_TEST_PERFORMANCE_TIMER_H_ 13 14 #include <cstddef> 15 #include <cstdint> 16 #include <optional> 17 #include <vector> 18 19 #include "system_wrappers/include/clock.h" 20 21 namespace webrtc { 22 namespace test { 23 24 class PerformanceTimer { 25 public: 26 explicit PerformanceTimer(int num_frames_to_process); 27 ~PerformanceTimer(); 28 29 void StartTimer(); 30 void StopTimer(); 31 32 double GetDurationAverage() const; 33 double GetDurationStandardDeviation() const; 34 35 // These methods are the same as those above, but they ignore the first 36 // `number_of_warmup_samples` measurements. 37 double GetDurationAverage(size_t number_of_warmup_samples) const; 38 double GetDurationStandardDeviation(size_t number_of_warmup_samples) const; 39 40 private: 41 webrtc::Clock* clock_; 42 std::optional<int64_t> start_timestamp_us_; 43 std::vector<int64_t> timestamps_us_; 44 }; 45 46 } // namespace test 47 } // namespace webrtc 48 49 #endif // MODULES_AUDIO_PROCESSING_TEST_PERFORMANCE_TIMER_H_