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

Side by Side Diff: bench/MutexBench.cpp

Issue 73643005: Implement a benchmark for GrResourceCache (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 1 month 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 | Annotate | Revision Log
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 "SkBenchmark.h" 7 #include "SkBenchmark.h"
8 #include "SkThread.h" 8 #include "SkThread.h"
9 9
10 class MutexBench : public SkBenchmark { 10 class MutexBench : public SkBenchmark {
11 public: 11 public:
12 MutexBench() { 12 MutexBench() {
13 fIsRendering = false;
14 } 13 }
14
15 virtual bool isSuitableFor(Backend backend) SK_OVERRIDE {
16 return backend == kNonRendering_Backend;
17 }
18
15 protected: 19 protected:
16 virtual const char* onGetName() { 20 virtual const char* onGetName() {
17 return "mutex"; 21 return "mutex";
18 } 22 }
19 23
20 virtual void onDraw(SkCanvas*) { 24 virtual void onDraw(SkCanvas*) {
21 SK_DECLARE_STATIC_MUTEX(mu); 25 SK_DECLARE_STATIC_MUTEX(mu);
22 for (int i = 0; i < this->getLoops(); i++) { 26 for (int i = 0; i < this->getLoops(); i++) {
23 mu.acquire(); 27 mu.acquire();
24 mu.release(); 28 mu.release();
25 } 29 }
26 } 30 }
27 31
28 private: 32 private:
29 typedef SkBenchmark INHERITED; 33 typedef SkBenchmark INHERITED;
30 }; 34 };
31 35
32 /////////////////////////////////////////////////////////////////////////////// 36 ///////////////////////////////////////////////////////////////////////////////
33 37
34 DEF_BENCH( return new MutexBench(); ) 38 DEF_BENCH( return new MutexBench(); )
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698