blob: 6c152a0dc0ff35b3e1c71c3893aea1f89c90a60e [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 {
11 enum {
12 N = SkBENCHLOOP(80),
13 M = SkBENCHLOOP(200)
14 };
15public:
16 MutexBench(void* param) : INHERITED(param) {
robertphillips@google.com433ce5e2012-09-17 10:49:30 +000017 fIsRendering = false;
tomhudson@google.com410e9dc2011-11-14 17:30:08 +000018 }
19protected:
20 virtual const char* onGetName() {
21 return "mutex";
22 }
23
24 virtual void onDraw(SkCanvas* canvas) {
25 for (int i = 0; i < N; i++) {
digit@google.com1771cbf2012-01-26 21:26:40 +000026 SK_DECLARE_STATIC_MUTEX(mu);
tomhudson@google.com410e9dc2011-11-14 17:30:08 +000027 for (int j = 0; j < M; j++) {
28 mu.acquire();
29 mu.release();
30 }
31 }
32 }
33
34private:
35 typedef SkBenchmark INHERITED;
36};
37
38///////////////////////////////////////////////////////////////////////////////
39
40static SkBenchmark* Fact(void* p) { return new MutexBench(p); }
41
42static BenchRegistry gReg01(Fact);