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" |
mtklein | 1b24933 | 2015-07-07 12:21:21 -0700 | [diff] [blame] | 8 | #include "SkMutex.h" |
tomhudson@google.com | 410e9dc | 2011-11-14 17:30:08 +0000 | [diff] [blame] | 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: |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 12 | bool isSuitableFor(Backend backend) override { |
commit-bot@chromium.org | 644629c | 2013-11-21 06:21:58 +0000 | [diff] [blame] | 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: |
mtklein | f059900 | 2015-07-13 06:18:39 -0700 | [diff] [blame] | 17 | const char* onGetName() override { |
tomhudson@google.com | 410e9dc | 2011-11-14 17:30:08 +0000 | [diff] [blame] | 18 | return "mutex"; |
| 19 | } |
| 20 | |
mtklein | f059900 | 2015-07-13 06:18:39 -0700 | [diff] [blame] | 21 | void onDraw(const int loops, SkCanvas*) override { |
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(); ) |