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

Unified Diff: bench/MathBench.cpp

Issue 24159009: Add SkDivMod with a special case for ARM. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: appease gcc on 10.6 Created 7 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 | include/core/SkMath.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: bench/MathBench.cpp
diff --git a/bench/MathBench.cpp b/bench/MathBench.cpp
index c34be44303c3fe0609eb11bd4c7565ccaa95b801..260159f3f0ebf58b513f1f16fb53e406130e9f1f 100644
--- a/bench/MathBench.cpp
+++ b/bench/MathBench.cpp
@@ -512,6 +512,42 @@ private:
///////////////////////////////////////////////////////////////////////////////
+template <typename T>
+class DivModBench : public SkBenchmark {
+ const char* fName;
+public:
+ explicit DivModBench(const char* name) : fName(name) {
+ fIsRendering = false;
+ }
+
+protected:
+ virtual const char* onGetName() {
+ return SkStringPrintf("divmod_%s", fName).c_str();
+ }
+
+ virtual void onDraw(SkCanvas*) {
+ volatile T a = 0, b = 0;
+ T div = 0, mod = 0;
+ for (int i = 0; i < this->getLoops(); i++) {
+ if ((T)i == 0) continue; // Small T will wrap around.
+ SkTDivMod((T)(i+1), (T)i, &div, &mod);
+ a ^= div;
+ b ^= mod;
+ }
+ }
+};
+DEF_BENCH(return new DivModBench<uint8_t>("uint8_t"))
+DEF_BENCH(return new DivModBench<uint16_t>("uint16_t"))
+DEF_BENCH(return new DivModBench<uint32_t>("uint32_t"))
+DEF_BENCH(return new DivModBench<uint64_t>("uint64_t"))
+
+DEF_BENCH(return new DivModBench<int8_t>("int8_t"))
+DEF_BENCH(return new DivModBench<int16_t>("int16_t"))
+DEF_BENCH(return new DivModBench<int32_t>("int32_t"))
+DEF_BENCH(return new DivModBench<int64_t>("int64_t"))
+
+///////////////////////////////////////////////////////////////////////////////
+
DEF_BENCH( return new NoOpMathBench(); )
DEF_BENCH( return new SlowISqrtMathBench(); )
DEF_BENCH( return new FastISqrtMathBench(); )
« no previous file with comments | « no previous file | include/core/SkMath.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698