tomhudson@google.com | 410e9dc | 2011-11-14 17:30:08 +0000 | [diff] [blame] | 1 | /* |
| 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 | |
| 10 | class MutexBench : public SkBenchmark { |
tomhudson@google.com | 410e9dc | 2011-11-14 17:30:08 +0000 | [diff] [blame] | 11 | public: |
mtklein@google.com | 410e6e8 | 2013-09-13 19:52:27 +0000 | [diff] [blame] | 12 | MutexBench() { |
robertphillips@google.com | 433ce5e | 2012-09-17 10:49:30 +0000 | [diff] [blame] | 13 | fIsRendering = false; |
tomhudson@google.com | 410e9dc | 2011-11-14 17:30:08 +0000 | [diff] [blame] | 14 | } |
| 15 | protected: |
| 16 | virtual const char* onGetName() { |
| 17 | return "mutex"; |
| 18 | } |
| 19 | |
sugoi@google.com | 77472f0 | 2013-03-05 18:50:01 +0000 | [diff] [blame] | 20 | virtual void onDraw(SkCanvas*) { |
mtklein@google.com | c289743 | 2013-09-10 19:23:38 +0000 | [diff] [blame] | 21 | SK_DECLARE_STATIC_MUTEX(mu); |
| 22 | for (int i = 0; i < this->getLoops(); i++) { |
| 23 | mu.acquire(); |
| 24 | mu.release(); |
tomhudson@google.com | 410e9dc | 2011-11-14 17:30:08 +0000 | [diff] [blame] | 25 | } |
| 26 | } |
| 27 | |
| 28 | private: |
| 29 | typedef SkBenchmark INHERITED; |
| 30 | }; |
| 31 | |
| 32 | /////////////////////////////////////////////////////////////////////////////// |
| 33 | |
mtklein@google.com | 410e6e8 | 2013-09-13 19:52:27 +0000 | [diff] [blame] | 34 | DEF_BENCH( return new MutexBench(); ) |