Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1655)

Unified Diff: bench/MutexBench.cpp

Issue 1352863004: Add shared mutex benchmark. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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; )
+
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698