aboutsummaryrefslogtreecommitdiffhomepage
path: root/bench
diff options
context:
space:
mode:
authorGravatar tomhudson@google.com <tomhudson@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2011-10-28 15:34:49 +0000
committerGravatar tomhudson@google.com <tomhudson@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2011-10-28 15:34:49 +0000
commitca529d303e50072aa25405c651b16f96b5b3fa4b (patch)
tree32ba9dd8ced02ba98a4ac128b98f605656ebd0e9 /bench
parent8382394bf260af223d5217ff8c45961f149bf1cf (diff)
In debug builds, only run each benchmark 1 time (test for assertion-breakage,
not performance). codereview.appspot.com/5314064/ git-svn-id: http://skia.googlecode.com/svn/trunk@2552 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'bench')
-rw-r--r--bench/BitmapBench.cpp2
-rw-r--r--bench/BlurBench.cpp2
-rw-r--r--bench/ChromeBench.cpp2
-rw-r--r--bench/DecodeBench.cpp2
-rw-r--r--bench/GradientBench.cpp4
-rw-r--r--bench/MathBench.cpp2
-rw-r--r--bench/MatrixBench.cpp10
-rw-r--r--bench/PathBench.cpp2
-rw-r--r--bench/RectBench.cpp2
-rw-r--r--bench/RepeatTileBench.cpp2
-rw-r--r--bench/ScalarBench.cpp2
-rw-r--r--bench/SkBenchmark.h6
-rw-r--r--bench/TextBench.cpp2
13 files changed, 23 insertions, 17 deletions
diff --git a/bench/BitmapBench.cpp b/bench/BitmapBench.cpp
index 7cce8b5643..3b169253ed 100644
--- a/bench/BitmapBench.cpp
+++ b/bench/BitmapBench.cpp
@@ -103,7 +103,7 @@ class BitmapBench : public SkBenchmark {
bool fForceUpdate; //bitmap marked as dirty before each draw. forces bitmap to be updated on device cache
int fTileX, fTileY; // -1 means don't use shader
SkString fName;
- enum { N = 300 };
+ enum { N = SkBENCHLOOP(300) };
public:
BitmapBench(void* param, bool isOpaque, SkBitmap::Config c,
bool forceUpdate = false, bool bitmapVolatile = false,
diff --git a/bench/BlurBench.cpp b/bench/BlurBench.cpp
index 666b26999c..1a69184dba 100644
--- a/bench/BlurBench.cpp
+++ b/bench/BlurBench.cpp
@@ -48,7 +48,7 @@ protected:
paint.setAntiAlias(true);
SkRandom rand;
- for (int i = 0; i < 10; i++) {
+ for (int i = 0; i < SkBENCHLOOP(10); i++) {
SkRect r = SkRect::MakeWH(rand.nextUScalar1() * 400,
rand.nextUScalar1() * 400);
r.offset(fRadius, fRadius);
diff --git a/bench/ChromeBench.cpp b/bench/ChromeBench.cpp
index 3373ef5c24..fc73d539d4 100644
--- a/bench/ChromeBench.cpp
+++ b/bench/ChromeBench.cpp
@@ -468,7 +468,7 @@ protected:
for (int i = 0; i < N; i++) {
SkRect current;
setRectangle(current, i);
- for (int j = 0; j < gmailScrollingRectSpec[i*3]; j++) {
+ for (int j = 0; j < SkBENCHLOOP(gmailScrollingRectSpec[i*3]); j++) {
canvas->drawRect(current, paint);
}
}
diff --git a/bench/DecodeBench.cpp b/bench/DecodeBench.cpp
index 01b4cfa88b..676169059f 100644
--- a/bench/DecodeBench.cpp
+++ b/bench/DecodeBench.cpp
@@ -18,7 +18,7 @@ class DecodeBench : public SkBenchmark {
const char* fFilename;
SkBitmap::Config fPrefConfig;
SkString fName;
- enum { N = 10 };
+ enum { N = SkBENCHLOOP(10) };
public:
DecodeBench(void* param, SkBitmap::Config c) : SkBenchmark(param) {
fFilename = this->findDefine("decode-filename");
diff --git a/bench/GradientBench.cpp b/bench/GradientBench.cpp
index 04923c9481..a5032eaa78 100644
--- a/bench/GradientBench.cpp
+++ b/bench/GradientBench.cpp
@@ -165,7 +165,7 @@ public:
{ SkIntToScalar(W), SkIntToScalar(H) }
};
- fCount = N * gGrads[gradType].fRepeat;
+ fCount = SkBENCHLOOP(N * gGrads[gradType].fRepeat);
fShader = gGrads[gradType].fMaker(pts, gGradData[0], tm, NULL, scale);
fGeomType = geomType;
}
@@ -223,7 +223,7 @@ protected:
{ SkIntToScalar(100), SkIntToScalar(100) },
};
- for (int i = 0; i < 1000; i++) {
+ for (int i = 0; i < SkBENCHLOOP(1000); i++) {
const int a = i % 256;
SkColor colors[] = {
SK_ColorBLACK,
diff --git a/bench/MathBench.cpp b/bench/MathBench.cpp
index 5726f38ede..6e3fec19c4 100644
--- a/bench/MathBench.cpp
+++ b/bench/MathBench.cpp
@@ -31,7 +31,7 @@ protected:
}
virtual void onDraw(SkCanvas* canvas) {
- int n = kLoop * this->mulLoopCount();
+ int n = SkBENCHLOOP(kLoop * this->mulLoopCount());
for (int i = 0; i < n; i++) {
this->performTest(fDst, fSrc, kBuffer);
}
diff --git a/bench/MatrixBench.cpp b/bench/MatrixBench.cpp
index 06669719fe..d88b41db62 100644
--- a/bench/MatrixBench.cpp
+++ b/bench/MatrixBench.cpp
@@ -28,7 +28,7 @@ protected:
}
virtual void onDraw(SkCanvas* canvas) {
- int n = N * this->mulLoopCount();
+ int n = SkBENCHLOOP(N * this->mulLoopCount());
for (int i = 0; i < n; i++) {
this->performTest();
}
@@ -271,7 +271,7 @@ class ScaleTransMixedMatrixBench : public MatrixBench {
fRandom.nextS(), fRandom.nextS(), fRandom.nextS(),
fRandom.nextS(), fRandom.nextS(), fRandom.nextS());
int i;
- for (i = 0; i < fCount; i++) {
+ for (i = 0; i < SkBENCHLOOP(fCount); i++) {
fSrc[i].fX = fRandom.nextSScalar1();
fSrc[i].fY = fRandom.nextSScalar1();
fDst[i].fX = fRandom.nextSScalar1();
@@ -282,7 +282,7 @@ class ScaleTransMixedMatrixBench : public MatrixBench {
virtual void performTest() {
SkPoint* dst = fDst;
const SkPoint* src = fSrc;
- int count = fCount;
+ int count = SkBENCHLOOP(fCount);
float mx = fMatrix[SkMatrix::kMScaleX];
float my = fMatrix[SkMatrix::kMScaleY];
float tx = fMatrix[SkMatrix::kMTransX];
@@ -308,7 +308,7 @@ class ScaleTransDoubleMatrixBench : public MatrixBench {
ScaleTransDoubleMatrixBench(void* p) : INHERITED(p, "scaletrans_double"), fCount (16) {
init9(fMatrix);
int i;
- for (i = 0; i < fCount; i++) {
+ for (i = 0; i < SkBENCHLOOP(fCount); i++) {
fSrc[i].fX = fRandom.nextSScalar1();
fSrc[i].fY = fRandom.nextSScalar1();
fDst[i].fX = fRandom.nextSScalar1();
@@ -319,7 +319,7 @@ class ScaleTransDoubleMatrixBench : public MatrixBench {
virtual void performTest() {
SkPoint* dst = fDst;
const SkPoint* src = fSrc;
- int count = fCount;
+ int count = SkBENCHLOOP(fCount);
// As doubles, on Z600 Linux systems this is 2.5x as expensive as mixed mode
float mx = (float) fMatrix[SkMatrix::kMScaleX];
float my = (float) fMatrix[SkMatrix::kMScaleY];
diff --git a/bench/PathBench.cpp b/bench/PathBench.cpp
index 1e3dc0cace..d3e01b7ff2 100644
--- a/bench/PathBench.cpp
+++ b/bench/PathBench.cpp
@@ -28,7 +28,7 @@ class PathBench : public SkBenchmark {
SkPaint fPaint;
SkString fName;
Flags fFlags;
- enum { N = 1000 };
+ enum { N = SkBENCHLOOP(1000) };
public:
PathBench(void* param, Flags flags) : INHERITED(param), fFlags(flags) {
fPaint.setStyle(flags & kStroke_Flag ? SkPaint::kStroke_Style :
diff --git a/bench/RectBench.cpp b/bench/RectBench.cpp
index 48937678f4..cef2e22d06 100644
--- a/bench/RectBench.cpp
+++ b/bench/RectBench.cpp
@@ -18,7 +18,7 @@ public:
enum {
W = 640,
H = 480,
- N = 300
+ N = SkBENCHLOOP(300)
};
SkRect fRects[N];
SkColor fColors[N];
diff --git a/bench/RepeatTileBench.cpp b/bench/RepeatTileBench.cpp
index ab0f687050..8470beddd2 100644
--- a/bench/RepeatTileBench.cpp
+++ b/bench/RepeatTileBench.cpp
@@ -86,7 +86,7 @@ static void convertToIndex666(const SkBitmap& src, SkBitmap* dst) {
class RepeatTileBench : public SkBenchmark {
SkPaint fPaint;
SkString fName;
- enum { N = 20 };
+ enum { N = SkBENCHLOOP(20) };
public:
RepeatTileBench(void* param, SkBitmap::Config c) : INHERITED(param) {
const int w = 50;
diff --git a/bench/ScalarBench.cpp b/bench/ScalarBench.cpp
index 05d56be4d4..8bedfbdede 100644
--- a/bench/ScalarBench.cpp
+++ b/bench/ScalarBench.cpp
@@ -28,7 +28,7 @@ protected:
}
virtual void onDraw(SkCanvas* canvas) {
- int n = N * this->mulLoopCount();
+ int n = SkBENCHLOOP(N * this->mulLoopCount());
for (int i = 0; i < n; i++) {
this->performTest();
}
diff --git a/bench/SkBenchmark.h b/bench/SkBenchmark.h
index adffd50e1d..5019b23e1a 100644
--- a/bench/SkBenchmark.h
+++ b/bench/SkBenchmark.h
@@ -13,6 +13,12 @@
#include "SkTDict.h"
#include "SkTRegistry.h"
+#ifdef SK_DEBUG
+ #define SkBENCHLOOP(n) 1
+#else
+ #define SkBENCHLOOP(n) n
+#endif
+
class SkCanvas;
class SkPaint;
diff --git a/bench/TextBench.cpp b/bench/TextBench.cpp
index 3bcd336a28..e252ead4a3 100644
--- a/bench/TextBench.cpp
+++ b/bench/TextBench.cpp
@@ -44,7 +44,7 @@ class TextBench : public SkBenchmark {
SkString fText;
SkString fName;
FontQuality fFQ;
- enum { N = 800 };
+ enum { N = SkBENCHLOOP(800) };
public:
TextBench(void* param, const char text[], int ps,
SkColor color, FontQuality fq) : INHERITED(param) {