ControlBench.cpp 861 B

1234567891011121314151617181920212223242526
  1. /*
  2. * Copyright 2015 Google Inc.
  3. *
  4. * Use of this source code is governed by a BSD-style license that can be
  5. * found in the LICENSE file.
  6. */
  7. #include "bench/Benchmark.h"
  8. // This benchmark's runtime should be fairly constant for a given machine,
  9. // so it can be used as a baseline to control for thermal or other throttling.
  10. struct ControlBench : public Benchmark {
  11. const char* onGetName() override { return "control"; }
  12. bool isSuitableFor(Backend backend) override { return backend == kNonRendering_Backend; }
  13. void onDraw(int loops, SkCanvas*) override {
  14. // Nothing terribly useful: force a memory read, a memory write, and some math.
  15. volatile uint32_t rand = 0;
  16. for (int i = 0; i < 1000*loops; i++) {
  17. rand *= 1664525;
  18. rand += 1013904223;
  19. }
  20. }
  21. };
  22. DEF_BENCH(return new ControlBench;)