blob: 3191ce17bef53c81f25ed50b812d26e1716c6b66 [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 */
7#include "SkBenchmark.h"
8#include "SkThread.h"
9
10class MutexBench : public SkBenchmark {
tomhudson@google.com410e9dc2011-11-14 17:30:08 +000011public:
commit-bot@chromium.org644629c2013-11-21 06:21:58 +000012 virtual bool isSuitableFor(Backend backend) SK_OVERRIDE {
13 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*) {
mtklein@google.comc2897432013-09-10 19:23:38 +000022 SK_DECLARE_STATIC_MUTEX(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:
30 typedef SkBenchmark INHERITED;
31};
32
33///////////////////////////////////////////////////////////////////////////////
34
mtklein@google.com410e6e82013-09-13 19:52:27 +000035DEF_BENCH( return new MutexBench(); )