OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 #include "Benchmark.h" | 7 #include "Benchmark.h" |
8 #include "SkMutex.h" | 8 #include "SkMutex.h" |
9 #include "SkSharedMutex.h" | 9 #include "SkSharedMutex.h" |
10 #include "SkSpinlock.h" | 10 #include "SkSpinlock.h" |
(...skipping 18 matching lines...) Expand all Loading... |
29 mu.acquire(); | 29 mu.acquire(); |
30 mu.release(); | 30 mu.release(); |
31 } | 31 } |
32 } | 32 } |
33 | 33 |
34 private: | 34 private: |
35 typedef Benchmark INHERITED; | 35 typedef Benchmark INHERITED; |
36 SkString fBenchName; | 36 SkString fBenchName; |
37 }; | 37 }; |
38 | 38 |
| 39 class SharedBench : public Benchmark { |
| 40 public: |
| 41 bool isSuitableFor(Backend backend) override { |
| 42 return backend == kNonRendering_Backend; |
| 43 } |
| 44 |
| 45 protected: |
| 46 const char* onGetName() override { |
| 47 return "SkSharedMutexSharedUncontendedBenchmark"; |
| 48 } |
| 49 |
| 50 void onDraw(const int loops, SkCanvas*) override { |
| 51 SkSharedMutex mu; |
| 52 for (int i = 0; i < loops; i++) { |
| 53 mu.acquireShared(); |
| 54 mu.releaseShared(); |
| 55 } |
| 56 } |
| 57 |
| 58 private: |
| 59 typedef Benchmark INHERITED; |
| 60 }; |
| 61 |
39 /////////////////////////////////////////////////////////////////////////////// | 62 /////////////////////////////////////////////////////////////////////////////// |
40 | 63 |
41 DEF_BENCH( return new MutexBench<SkSharedMutex>(SkString("SkSharedMutex")); ) | 64 DEF_BENCH( return new MutexBench<SkSharedMutex>(SkString("SkSharedMutex")); ) |
42 DEF_BENCH( return new MutexBench<SkMutex>(SkString("SkMutex")); ) | 65 DEF_BENCH( return new MutexBench<SkMutex>(SkString("SkMutex")); ) |
43 DEF_BENCH( return new MutexBench<SkSpinlock>(SkString("SkSpinlock")); ) | 66 DEF_BENCH( return new MutexBench<SkSpinlock>(SkString("SkSpinlock")); ) |
| 67 DEF_BENCH( return new SharedBench; ) |
| 68 |
OLD | NEW |