aboutsummaryrefslogtreecommitdiffhomepage
path: root/bench/MutexBench.cpp
diff options
context:
space:
mode:
authorGravatar herb <herb@google.com>2015-09-18 10:50:35 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2015-09-18 10:50:35 -0700
commitd32087a613fde2623bbe0abfe551164fdf3d633e (patch)
treefc57d5aea76129755c4d7890e9c444e61958f91e /bench/MutexBench.cpp
parentf2608513626264459a00388537175600b515cae2 (diff)
Add shared mutex benchmark.
Diffstat (limited to 'bench/MutexBench.cpp')
-rw-r--r--bench/MutexBench.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/bench/MutexBench.cpp b/bench/MutexBench.cpp
index ad9a92a90b..6dd4e5346f 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; )
+