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 | */ |
tfarina | f168b86 | 2014-06-19 12:32:29 -0700 | [diff] [blame] | 7 | #include "Benchmark.h" |
tomhudson@google.com | 410e9dc | 2011-11-14 17:30:08 +0000 | [diff] [blame] | 8 | #include "SkThread.h" |
| 9 | |
tfarina | f168b86 | 2014-06-19 12:32:29 -0700 | [diff] [blame] | 10 | class MutexBench : public Benchmark { |
tomhudson@google.com | 410e9dc | 2011-11-14 17:30:08 +0000 | [diff] [blame] | 11 | public: |
commit-bot@chromium.org | 644629c | 2013-11-21 06:21:58 +0000 | [diff] [blame] | 12 | virtual bool isSuitableFor(Backend backend) SK_OVERRIDE { |
| 13 | return backend == kNonRendering_Backend; |
tomhudson@google.com | 410e9dc | 2011-11-14 17:30:08 +0000 | [diff] [blame] | 14 | } |
commit-bot@chromium.org | 644629c | 2013-11-21 06:21:58 +0000 | [diff] [blame] | 15 | |
tomhudson@google.com | 410e9dc | 2011-11-14 17:30:08 +0000 | [diff] [blame] | 16 | protected: |
| 17 | virtual const char* onGetName() { |
| 18 | return "mutex"; |
| 19 | } |
| 20 | |
commit-bot@chromium.org | 3361471 | 2013-12-03 18:17:16 +0000 | [diff] [blame] | 21 | virtual void onDraw(const int loops, SkCanvas*) { |
bungeman | d6aeb6d | 2014-07-25 11:52:47 -0700 | [diff] [blame] | 22 | SkMutex mu; |
commit-bot@chromium.org | 3361471 | 2013-12-03 18:17:16 +0000 | [diff] [blame] | 23 | for (int i = 0; i < loops; i++) { |
mtklein@google.com | c289743 | 2013-09-10 19:23:38 +0000 | [diff] [blame] | 24 | mu.acquire(); |
| 25 | mu.release(); |
tomhudson@google.com | 410e9dc | 2011-11-14 17:30:08 +0000 | [diff] [blame] | 26 | } |
| 27 | } |
| 28 | |
| 29 | private: |
tfarina | f168b86 | 2014-06-19 12:32:29 -0700 | [diff] [blame] | 30 | typedef Benchmark INHERITED; |
tomhudson@google.com | 410e9dc | 2011-11-14 17:30:08 +0000 | [diff] [blame] | 31 | }; |
| 32 | |
| 33 | /////////////////////////////////////////////////////////////////////////////// |
| 34 | |
mtklein@google.com | 410e6e8 | 2013-09-13 19:52:27 +0000 | [diff] [blame] | 35 | DEF_BENCH( return new MutexBench(); ) |