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
This commit is contained in:
tomhudson@google.com 2011-10-28 15:34:49 +00:00
parent 8382394bf2
commit ca529d303e
13 changed files with 23 additions and 17 deletions

View File

@ -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,

View File

@ -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);

View File

@ -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);
}
}

View File

@ -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");

View File

@ -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,

View File

@ -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);
}

View File

@ -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];

View File

@ -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 :

View File

@ -18,7 +18,7 @@ public:
enum {
W = 640,
H = 480,
N = 300
N = SkBENCHLOOP(300)
};
SkRect fRects[N];
SkColor fColors[N];

View File

@ -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;

View File

@ -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();
}

View File

@ -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;

View File

@ -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) {