aboutsummaryrefslogtreecommitdiffhomepage
path: root/bench/MutexBench.cpp
diff options
context:
space:
mode:
authorGravatar herb <herb@google.com>2015-09-18 09:24:18 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2015-09-18 09:24:18 -0700
commitbcfd511eb1aada39622116fd1df8178b58650fba (patch)
treea6d17a0f3d840684d0879e7469f6d537ea7ec5ec /bench/MutexBench.cpp
parent5ce341fcd7eb63fc98c182b34c5503fb1780faf5 (diff)
Benchmark all mutex implementations.
Diffstat (limited to 'bench/MutexBench.cpp')
-rw-r--r--bench/MutexBench.cpp14
1 files changed, 11 insertions, 3 deletions
diff --git a/bench/MutexBench.cpp b/bench/MutexBench.cpp
index 2565d3860e..ad9a92a90b 100644
--- a/bench/MutexBench.cpp
+++ b/bench/MutexBench.cpp
@@ -6,20 +6,25 @@
*/
#include "Benchmark.h"
#include "SkMutex.h"
+#include "SkSharedMutex.h"
+#include "SkSpinlock.h"
+#include "SkString.h"
+template <typename Mutex>
class MutexBench : public Benchmark {
public:
+ MutexBench(SkString benchPrefix) : fBenchName(benchPrefix += "UncontendedBenchmark") { }
bool isSuitableFor(Backend backend) override {
return backend == kNonRendering_Backend;
}
protected:
const char* onGetName() override {
- return "mutex";
+ return fBenchName.c_str();
}
void onDraw(const int loops, SkCanvas*) override {
- SkMutex mu;
+ Mutex mu;
for (int i = 0; i < loops; i++) {
mu.acquire();
mu.release();
@@ -28,8 +33,11 @@ protected:
private:
typedef Benchmark INHERITED;
+ SkString fBenchName;
};
///////////////////////////////////////////////////////////////////////////////
-DEF_BENCH( return new MutexBench(); )
+DEF_BENCH( return new MutexBench<SkSharedMutex>(SkString("SkSharedMutex")); )
+DEF_BENCH( return new MutexBench<SkMutex>(SkString("SkMutex")); )
+DEF_BENCH( return new MutexBench<SkSpinlock>(SkString("SkSpinlock")); )