Index: bench/MutexBench.cpp |
diff --git a/bench/MutexBench.cpp b/bench/MutexBench.cpp |
index ad9a92a90b3146ea047690833e973dcfb13a8423..6dd4e5346f7dbf11a826431dc41ec3187b2b5448 100644 |
--- a/bench/MutexBench.cpp |
+++ b/bench/MutexBench.cpp |
@@ -36,8 +36,33 @@ private: |
SkString fBenchName; |
}; |
+class SharedBench : public Benchmark { |
+public: |
+ bool isSuitableFor(Backend backend) override { |
+ return backend == kNonRendering_Backend; |
+ } |
+ |
+protected: |
+ const char* onGetName() override { |
+ return "SkSharedMutexSharedUncontendedBenchmark"; |
+ } |
+ |
+ void onDraw(const int loops, SkCanvas*) override { |
+ SkSharedMutex mu; |
+ for (int i = 0; i < loops; i++) { |
+ mu.acquireShared(); |
+ mu.releaseShared(); |
+ } |
+ } |
+ |
+private: |
+ typedef Benchmark INHERITED; |
+}; |
+ |
/////////////////////////////////////////////////////////////////////////////// |
DEF_BENCH( return new MutexBench<SkSharedMutex>(SkString("SkSharedMutex")); ) |
DEF_BENCH( return new MutexBench<SkMutex>(SkString("SkMutex")); ) |
DEF_BENCH( return new MutexBench<SkSpinlock>(SkString("SkSpinlock")); ) |
+DEF_BENCH( return new SharedBench; ) |
+ |