blob: d9b427b444e1bc516ce24a34dda80e689496612a [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) {
17
18 }
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++) {
26 SkMutex mu;
27 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);
43