blob: 5a7058d5e02c578b34f809a0df6905178883f9f8 [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:
12 MutexBench(void* param) : INHERITED(param) {
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
34static SkBenchmark* Fact(void* p) { return new MutexBench(p); }
35
36static BenchRegistry gReg01(Fact);