Make bench_pictures output a meaningful config name.
authorscroggo@google.com <scroggo@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Fri, 2 Nov 2012 22:01:26 +0000 (22:01 +0000)
committerscroggo@google.com <scroggo@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Fri, 2 Nov 2012 22:01:26 +0000 (22:01 +0000)
Review URL: https://codereview.appspot.com/6813074

git-svn-id: http://skia.googlecode.com/svn/trunk@6288 2bbb7eff-a529-9590-31e7-b0007b416f81

tools/PictureBenchmark.cpp
tools/PictureRenderer.cpp
tools/PictureRenderer.h

index fbf1585d1e3e2ed90c98f4409a90d0b57940efc1..ca7795f7b74b70795266e5f491f7423af064e4ab 100644 (file)
@@ -95,9 +95,9 @@ void PictureBenchmark::run(SkPicture* pict) {
         timerData.appendTimes(timer, fRepeats - 1 == i);
     }
 
-    const char* configName = usingGpu ? "gpu" : "raster";
+    SkString configName = fRenderer->getConfigName();
     SkString result = timerData.getResult(fLogPerIter, fPrintMin, fRepeats,
-                                          configName, fShowWallTime, fShowTruncatedWallTime,
+                                          configName.c_str(), fShowWallTime, fShowTruncatedWallTime,
                                           fShowCpuTime, fShowTruncatedCpuTime,
                                           usingGpu && fShowGpuTime);
     result.append("\n");
index 745bec00f18336f0e867a6a4b5310d470a9e3c63..d407b0eea81aa6164d400e9ce0e79272c27e4103 100644 (file)
@@ -174,6 +174,10 @@ bool RecordPictureRenderer::render(const SkString*) {
     return false;
 }
 
+SkString RecordPictureRenderer::getConfigNameInternal() {
+    return SkString("record");
+}
+
 ///////////////////////////////////////////////////////////////////////////////////////////////
 
 bool PipePictureRenderer::render(const SkString* path) {
@@ -195,6 +199,10 @@ bool PipePictureRenderer::render(const SkString* path) {
     return true;
 }
 
+SkString PipePictureRenderer::getConfigNameInternal() {
+    return SkString("pipe");
+}
+
 ///////////////////////////////////////////////////////////////////////////////////////////////
 
 void SimplePictureRenderer::init(SkPicture* picture) {
@@ -217,6 +225,10 @@ bool SimplePictureRenderer::render(const SkString* path) {
     return true;
 }
 
+SkString SimplePictureRenderer::getConfigNameInternal() {
+    return SkString("simple");
+}
+
 ///////////////////////////////////////////////////////////////////////////////////////////////
 
 TiledPictureRenderer::TiledPictureRenderer()
@@ -361,6 +373,29 @@ SkCanvas* TiledPictureRenderer::setupCanvas(int width, int height) {
     canvas->clipRect(clip);
     return canvas;
 }
+
+SkString TiledPictureRenderer::getConfigNameInternal() {
+    SkString name;
+    if (fTileMinPowerOf2Width > 0) {
+        name.append("pow2tile_");
+        name.appendf("%i", fTileMinPowerOf2Width);
+    } else {
+        name.append("tile_");
+        if (fTileWidthPercentage > 0) {
+            name.appendf("%.f%%", fTileWidthPercentage);
+        } else {
+            name.appendf("%i", fTileWidth);
+        }
+    }
+    name.append("x");
+    if (fTileHeightPercentage > 0) {
+        name.appendf("%.f%%", fTileHeightPercentage);
+    } else {
+        name.appendf("%i", fTileHeight);
+    }
+    return name;
+}
+
 ///////////////////////////////////////////////////////////////////////////////////////////////
 
 // Holds all of the information needed to draw a set of tiles.
@@ -484,6 +519,12 @@ MultiCorePictureRenderer::~MultiCorePictureRenderer() {
     SkDELETE_ARRAY(fPictureClones);
 }
 
+SkString MultiCorePictureRenderer::getConfigNameInternal() {
+    SkString name = this->INHERITED::getConfigNameInternal();
+    name.appendf("_multi_%i_threads", fNumThreads);
+    return name;
+}
+
 ///////////////////////////////////////////////////////////////////////////////////////////////
 
 void PlaybackCreationRenderer::setup() {
@@ -499,6 +540,10 @@ bool PlaybackCreationRenderer::render(const SkString*) {
     return false;
 }
 
+SkString PlaybackCreationRenderer::getConfigNameInternal() {
+    return SkString("playback_creation");
+}
+
 ///////////////////////////////////////////////////////////////////////////////////////////////
 // SkPicture variants for each BBoxHierarchy type
 
index 3ff8967d446147e6aed24950cf439097a62bfcda..a3c879a2ab48d0a1542d3432887b75611ceaa311 100644 (file)
@@ -91,6 +91,22 @@ public:
 
     virtual SkString getNormalTimeFormat() { return SkString("%6.2f"); }
 
+    /**
+     * Reports the configuration of this PictureRenderer.
+     */
+    SkString getConfigName() {
+        SkString config = this->getConfigNameInternal();
+        if (kRTree_BBoxHierarchyType == fBBoxHierarchyType) {
+            config.append("_rtree");
+        }
+#if SK_SUPPORT_GPU
+        if (this->isUsingGpuDevice()) {
+            config.append("_gpu");
+        }
+#endif
+        return config;
+    }
+
 #if SK_SUPPORT_GPU
     bool isUsingGpuDevice() {
         return kGPU_DeviceType == fDeviceType;
@@ -137,6 +153,8 @@ protected:
 #endif
 
 private:
+    virtual SkString getConfigNameInternal() = 0;
+
     typedef SkRefCnt INHERITED;
 };
 
@@ -150,6 +168,9 @@ class RecordPictureRenderer : public PictureRenderer {
     virtual SkString getPerIterTimeFormat() SK_OVERRIDE { return SkString("%.4f"); }
 
     virtual SkString getNormalTimeFormat() SK_OVERRIDE { return SkString("%6.4f"); }
+
+private:
+    virtual SkString getConfigNameInternal() SK_OVERRIDE;
 };
 
 class PipePictureRenderer : public PictureRenderer {
@@ -157,6 +178,8 @@ public:
     virtual bool render(const SkString*) SK_OVERRIDE;
 
 private:
+    virtual SkString getConfigNameInternal() SK_OVERRIDE;
+
     typedef PictureRenderer INHERITED;
 };
 
@@ -167,6 +190,8 @@ public:
     virtual bool render(const SkString*) SK_OVERRIDE;
 
 private:
+    virtual SkString getConfigNameInternal() SK_OVERRIDE;
+
     typedef PictureRenderer INHERITED;
 };
 
@@ -231,9 +256,11 @@ public:
     }
 
 protected:
-    virtual SkCanvas* setupCanvas(int width, int height) SK_OVERRIDE;
     SkTDArray<SkRect> fTileRects;
 
+    virtual SkCanvas* setupCanvas(int width, int height) SK_OVERRIDE;
+    virtual SkString getConfigNameInternal() SK_OVERRIDE;
+
 private:
     int               fTileWidth;
     int               fTileHeight;
@@ -265,6 +292,8 @@ public:
     virtual void end() SK_OVERRIDE;
 
 private:
+    virtual SkString getConfigNameInternal() SK_OVERRIDE;
+
     const int            fNumThreads;
     SkTDArray<SkCanvas*> fCanvasPool;
     SkThreadPool         fThreadPool;
@@ -291,6 +320,9 @@ public:
 
 private:
     SkAutoTUnref<SkPicture> fReplayer;
+
+    virtual SkString getConfigNameInternal() SK_OVERRIDE;
+
     typedef PictureRenderer INHERITED;
 };