blob: 7fd8fabba14f601ca4d3eec23f8ff38a0d9d5ebf [file] [log] [blame]
tomhudson@google.com410e9dc2011-11-14 17:30:08 +00001/*
2 * Copyright 2011 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 */
tfarinaf168b862014-06-19 12:32:29 -07007#include "Benchmark.h"
tomhudson@google.com410e9dc2011-11-14 17:30:08 +00008#include "SkThread.h"
9
tfarinaf168b862014-06-19 12:32:29 -070010class MutexBench : public Benchmark {
tomhudson@google.com410e9dc2011-11-14 17:30:08 +000011public:
mtklein36352bf2015-03-25 18:17:31 -070012 bool isSuitableFor(Backend backend) override {
commit-bot@chromium.org644629c2013-11-21 06:21:58 +000013 return backend == kNonRendering_Backend;
tomhudson@google.com410e9dc2011-11-14 17:30:08 +000014 }
commit-bot@chromium.org644629c2013-11-21 06:21:58 +000015
tomhudson@google.com410e9dc2011-11-14 17:30:08 +000016protected:
17 virtual const char* onGetName() {
18 return "mutex";
19 }
20
commit-bot@chromium.org33614712013-12-03 18:17:16 +000021 virtual void onDraw(const int loops, SkCanvas*) {
bungemand6aeb6d2014-07-25 11:52:47 -070022 SkMutex mu;
commit-bot@chromium.org33614712013-12-03 18:17:16 +000023 for (int i = 0; i < loops; i++) {
mtklein@google.comc2897432013-09-10 19:23:38 +000024 mu.acquire();
25 mu.release();
tomhudson@google.com410e9dc2011-11-14 17:30:08 +000026 }
27 }
28
29private:
tfarinaf168b862014-06-19 12:32:29 -070030 typedef Benchmark INHERITED;
tomhudson@google.com410e9dc2011-11-14 17:30:08 +000031};
32
33///////////////////////////////////////////////////////////////////////////////
34
mtklein@google.com410e6e82013-09-13 19:52:27 +000035DEF_BENCH( return new MutexBench(); )