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

Unified Diff: bench/RefCntBench.cpp

Issue 377073002: Add support for 64bit atomics (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Use function versions on windows Created 6 years, 5 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 | include/core/SkThread.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: bench/RefCntBench.cpp
diff --git a/bench/RefCntBench.cpp b/bench/RefCntBench.cpp
index 351513b83182edccbfaac3baf26ed0f3b4b9dde0..f846b1ac604a55f222788bcda8873bfea0a0faaa 100644
--- a/bench/RefCntBench.cpp
+++ b/bench/RefCntBench.cpp
@@ -14,6 +14,54 @@ enum {
M = 2
};
+class AtomicInc32 : public Benchmark {
+public:
+ AtomicInc32() : fX(0) {}
+
+ virtual bool isSuitableFor(Backend backend) SK_OVERRIDE {
+ return backend == kNonRendering_Backend;
+ }
+
+protected:
+ virtual const char* onGetName() {
+ return "atomic_inc_32";
+ }
+
+ virtual void onDraw(const int loops, SkCanvas*) {
+ for (int i = 0; i < loops; ++i) {
+ sk_atomic_inc(&fX);
+ }
+ }
+
+private:
+ int32_t fX;
+ typedef Benchmark INHERITED;
+};
+
+class AtomicInc64 : public Benchmark {
+public:
+ AtomicInc64() : fX(0) {}
+
+ virtual bool isSuitableFor(Backend backend) SK_OVERRIDE {
+ return backend == kNonRendering_Backend;
+ }
+
+protected:
+ virtual const char* onGetName() {
+ return "atomic_inc_64";
+ }
+
+ virtual void onDraw(const int loops, SkCanvas*) {
+ for (int i = 0; i < loops; ++i) {
+ sk_atomic_inc(&fX);
+ }
+ }
+
+private:
+ int64_t fX;
+ typedef Benchmark INHERITED;
+};
+
class RefCntBench_Stack : public Benchmark {
public:
virtual bool isSuitableFor(Backend backend) SK_OVERRIDE {
@@ -191,6 +239,9 @@ private:
///////////////////////////////////////////////////////////////////////////////
+DEF_BENCH( return new AtomicInc32(); )
+DEF_BENCH( return new AtomicInc64(); )
+
DEF_BENCH( return new RefCntBench_Stack(); )
DEF_BENCH( return new RefCntBench_Heap(); )
DEF_BENCH( return new RefCntBench_New(); )
« no previous file with comments | « no previous file | include/core/SkThread.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698