performance_timer.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. #ifndef MODULES_AUDIO_PROCESSING_TEST_PERFORMANCE_TIMER_H_
  11. #define MODULES_AUDIO_PROCESSING_TEST_PERFORMANCE_TIMER_H_
  12. #include <vector>
  13. #include "absl/types/optional.h"
  14. #include "system_wrappers/include/clock.h"
  15. namespace webrtc {
  16. namespace test {
  17. class PerformanceTimer {
  18. public:
  19. explicit PerformanceTimer(int num_frames_to_process);
  20. ~PerformanceTimer();
  21. void StartTimer();
  22. void StopTimer();
  23. double GetDurationAverage() const;
  24. double GetDurationStandardDeviation() const;
  25. // These methods are the same as those above, but they ignore the first
  26. // |number_of_warmup_samples| measurements.
  27. double GetDurationAverage(size_t number_of_warmup_samples) const;
  28. double GetDurationStandardDeviation(size_t number_of_warmup_samples) const;
  29. private:
  30. webrtc::Clock* clock_;
  31. absl::optional<int64_t> start_timestamp_us_;
  32. std::vector<int64_t> timestamps_us_;
  33. };
  34. } // namespace test
  35. } // namespace webrtc
  36. #endif // MODULES_AUDIO_PROCESSING_TEST_PERFORMANCE_TIMER_H_