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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
OLDNEW
« 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