mtklein | 44d43d8 | 2015-05-06 12:42:04 -0700 | [diff] [blame] | 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 | |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 8 | #include "bench/Benchmark.h" |
mtklein | 44d43d8 | 2015-05-06 12:42:04 -0700 | [diff] [blame] | 9 | |
| 10 | // This benchmark's runtime should be fairly constant for a given machine, |
| 11 | // so it can be used as a baseline to control for thermal or other throttling. |
| 12 | |
| 13 | struct ControlBench : public Benchmark { |
| 14 | const char* onGetName() override { return "control"; } |
| 15 | bool isSuitableFor(Backend backend) override { return backend == kNonRendering_Backend; } |
| 16 | |
mtklein | a1ebeb2 | 2015-10-01 09:43:39 -0700 | [diff] [blame] | 17 | void onDraw(int loops, SkCanvas*) override { |
mtklein | 44d43d8 | 2015-05-06 12:42:04 -0700 | [diff] [blame] | 18 | // Nothing terribly useful: force a memory read, a memory write, and some math. |
Brian Salomon | 54fd96b | 2021-08-05 12:16:07 -0400 | [diff] [blame] | 19 | SK_MAYBE_UNUSED volatile uint32_t rand = 0; |
mtklein | 44d43d8 | 2015-05-06 12:42:04 -0700 | [diff] [blame] | 20 | for (int i = 0; i < 1000*loops; i++) { |
| 21 | rand *= 1664525; |
| 22 | rand += 1013904223; |
| 23 | } |
| 24 | } |
| 25 | }; |
| 26 | DEF_BENCH(return new ControlBench;) |