cpu_speed_experiment.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /*
  2. * Copyright 2018 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 RTC_BASE_EXPERIMENTS_CPU_SPEED_EXPERIMENT_H_
  11. #define RTC_BASE_EXPERIMENTS_CPU_SPEED_EXPERIMENT_H_
  12. #include <vector>
  13. #include "absl/types/optional.h"
  14. #include "rtc_base/experiments/field_trial_parser.h"
  15. namespace webrtc {
  16. class CpuSpeedExperiment {
  17. public:
  18. CpuSpeedExperiment();
  19. ~CpuSpeedExperiment();
  20. // Example:
  21. // WebRTC-VP8-CpuSpeed-Arm/pixels:100|200|300,cpu_speed:-1|-2|-3/
  22. // pixels <= 100 -> cpu speed: -1
  23. // pixels <= 200 -> cpu speed: -2
  24. // pixels <= 300 -> cpu speed: -3
  25. // WebRTC-VP8-CpuSpeed-Arm/pixels:100|200|300,cpu_speed:-1|-2|-3/,
  26. // cpu_speed_le_cores:-4|-5|-6,cores:3/
  27. // If |num_cores| > 3
  28. // pixels <= 100 -> cpu speed: -1
  29. // pixels <= 200 -> cpu speed: -2
  30. // pixels <= 300 -> cpu speed: -3
  31. // else
  32. // pixels <= 100 -> cpu speed: -4
  33. // pixels <= 200 -> cpu speed: -5
  34. // pixels <= 300 -> cpu speed: -6
  35. struct Config {
  36. int pixels = 0; // The video frame size.
  37. int cpu_speed = 0; // The |cpu_speed| to be used if the frame size is less
  38. // than or equal to |pixels|.
  39. // Optional.
  40. int cpu_speed_le_cores = 0; // Same as |cpu_speed| above but only used if
  41. // |num_cores| <= |cores_|.
  42. };
  43. // Gets the cpu speed based on |pixels| and |num_cores|.
  44. absl::optional<int> GetValue(int pixels, int num_cores) const;
  45. private:
  46. std::vector<Config> configs_;
  47. // Threshold for when to use |cpu_speed_le_cores|.
  48. FieldTrialOptional<int> cores_;
  49. };
  50. } // namespace webrtc
  51. #endif // RTC_BASE_EXPERIMENTS_CPU_SPEED_EXPERIMENT_H_