blob: 1d037ec1cd27da247e63c012c641361315918dc5 [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:
mtklein@google.com410e6e82013-09-13 19:52:27 +000012 MutexBench() {
robertphillips@google.com433ce5e2012-09-17 10:49:30 +000013 fIsRendering = false;
tomhudson@google.com410e9dc2011-11-14 17:30:08 +000014 }
15protected:
16 virtual const char* onGetName() {
17 return "mutex";
18 }
19
sugoi@google.com77472f02013-03-05 18:50:01 +000020 virtual void onDraw(SkCanvas*) {
mtklein@google.comc2897432013-09-10 19:23:38 +000021 SK_DECLARE_STATIC_MUTEX(mu);
22 for (int i = 0; i < this->getLoops(); i++) {
23 mu.acquire();
24 mu.release();
tomhudson@google.com410e9dc2011-11-14 17:30:08 +000025 }
26 }
27
28private:
29 typedef SkBenchmark INHERITED;
30};
31
32///////////////////////////////////////////////////////////////////////////////
33
mtklein@google.com410e6e82013-09-13 19:52:27 +000034DEF_BENCH( return new MutexBench(); )