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

Unified Diff: bench/MathBench.cpp

Issue 1022543003: replace SkFixedDiv impl with native 64bit math (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 9 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/SkFixed.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 5b46d1c704c835e6390a7df60ee50a03206cc5c4..e0d519407f4813c4bb96d2644b9c8ec541bf84ee 100644
--- a/bench/MathBench.cpp
+++ b/bench/MathBench.cpp
@@ -545,6 +545,50 @@ private:
///////////////////////////////////////////////////////////////////////////////
+class DivBitsBench : public Benchmark {
+protected:
+ enum {
+ N = 1000
+ };
+ volatile int32_t fSrc[N], fDst[N];
+public:
+ DivBitsBench() {
+ SkRandom rand;
+ for (int i = 0; i < N; ++i) {
+ fSrc[i] = rand.nextU();
+ }
+ }
+protected:
+ virtual void onDraw(const int loops, SkCanvas*) {
+ for (int j = 0; j < loops; ++j) {
+ for (int i = 0; i < N - 4; ++i) {
+ fDst[i] = SkDivBits(fSrc[i], fSrc[i] >> 3, 16);
+ }
+ }
+ }
+ virtual const char* onGetName() {
+ return "divbits";
+ }
+};
+DEF_BENCH( return new DivBitsBench; )
+
+class FixedDivBench : public DivBitsBench {
+protected:
+ virtual void onDraw(const int loops, SkCanvas*) {
+ for (int j = 0; j < loops; ++j) {
+ for (int i = 0; i < N - 4; ++i) {
+ fDst[i] = SkFixedDiv(fSrc[i], fSrc[i] >> 3);
+ }
+ }
+ }
+ virtual const char* onGetName() {
+ return "fixeddiv";
+ }
+};
+DEF_BENCH( return new FixedDivBench; )
+
+///////////////////////////////////////////////////////////////////////////////
+
template <typename T>
class DivModBench : public Benchmark {
SkString fName;
« no previous file with comments | « no previous file | include/core/SkFixed.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698