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