cpu_reduction_experiment.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435
  1. // Copyright 2022 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef BASE_CPU_REDUCTION_EXPERIMENT_H_
  5. #define BASE_CPU_REDUCTION_EXPERIMENT_H_
  6. #include "base/base_export.h"
  7. namespace base {
  8. // Returns whether the cpu cycle reduction experiment is running.
  9. // The goal of this experiment is to better understand the relationship between
  10. // total CPU cycles used across the fleet and top-line chrome metrics.
  11. BASE_EXPORT bool IsRunningCpuReductionExperiment();
  12. // Must be called after FeatureList initialization and while chrome is still
  13. // single-threaded.
  14. BASE_EXPORT void InitializeCpuReductionExperiment();
  15. // This is a helper class to reduce common duplicate code. If the CPU reduction
  16. // experiment is running, then ShouldLogHistograms returns true on every 1000th
  17. // call. Otherwise it always returns true.
  18. class BASE_EXPORT CpuReductionExperimentFilter {
  19. public:
  20. // Returns true on the first call, and every 1000th call after that.
  21. bool ShouldLogHistograms();
  22. private:
  23. int counter_ = 0;
  24. };
  25. } // namespace base
  26. #endif // BASE_CPU_REDUCTION_EXPERIMENT_H_