Add JSON logging support to bench_pictures by adding a PictureResultsWriter class (in tools/PictureResultsWriter.h) to process logging information, using a very similar style as bench/ResultsWriter.h
JSON format described in code, above PictureJSONResultsWriter class
BUG=skia:
R=bensong@google.com, jcgregorio@google.com
Author: kelvinly@google.com
Review URL: https://codereview.chromium.org/286903025
git-svn-id: http://skia.googlecode.com/svn/trunk@14906 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/tools/PictureBenchmark.cpp b/tools/PictureBenchmark.cpp
index 6c0325e..f1d0003 100644
--- a/tools/PictureBenchmark.cpp
+++ b/tools/PictureBenchmark.cpp
@@ -5,7 +5,6 @@
* found in the LICENSE file.
*/
-#include "SkBenchLogger.h"
#include "BenchTimer.h"
#include "PictureBenchmark.h"
#include "SkCanvas.h"
@@ -17,13 +16,13 @@
PictureBenchmark::PictureBenchmark()
: fRepeats(1)
-, fLogger(NULL)
, fRenderer(NULL)
, fTimerResult(TimerData::kAvg_Result)
, fTimerTypes(0)
, fTimeIndividualTiles(false)
, fPurgeDecodedTex(false)
, fPreprocess(false)
+, fWriter(NULL)
{}
PictureBenchmark::~PictureBenchmark() {
@@ -52,12 +51,6 @@
return SkNEW_ARGS(BenchTimer, (NULL));
}
-void PictureBenchmark::logProgress(const char msg[]) {
- if (fLogger != NULL) {
- fLogger->logProgress(msg);
- }
-}
-
PictureRenderer* PictureBenchmark::setRenderer(sk_tools::PictureRenderer* renderer) {
SkRefCnt_SafeAssign(fRenderer, renderer);
return renderer;
@@ -137,10 +130,6 @@
return;
}
- // Insert a newline so that each tile is reported on its own line (separate from the line
- // that describes the skp being run).
- this->logProgress("\n");
-
int x, y;
while (tiledRenderer->nextTile(x, y)) {
// There are two timers, which will behave slightly differently:
@@ -184,8 +173,8 @@
SkAssertResult(longRunningTimerData.appendTimes(longRunningTimer.get()));
}
- SkString configName = tiledRenderer->getConfigName();
- configName.appendf(": tile [%i,%i] out of [%i,%i]", x, y, xTiles, yTiles);
+ fWriter->tileConfig(tiledRenderer->getConfigName());
+ fWriter->tileMeta(x, y, xTiles, yTiles);
// TODO(borenet): Turn off per-iteration tile time reporting for now.
// Avoiding logging the time for every iteration for each tile cuts
@@ -193,22 +182,23 @@
// we're loading the bench data directly into a data store and are no
// longer generating SVG graphs.
#if 0
- SkString result = perTileTimerData.getResult(timeFormat.c_str(), fTimerResult,
- configName.c_str(), timerTypes);
- result.append("\n");
- this->logProgress(result.c_str());
+ fWriter->tileData(
+ &perTileTimerData,
+ timeFormat.c_str(),
+ fTimerResult,
+ timerTypes);
#endif
if (fPurgeDecodedTex) {
- configName.append(" <withPurging>");
+ fWriter->addTileFlag(PictureResultsWriter::kPurging);
}
- configName.append(" <averaged>");
- SkString longRunningResult = longRunningTimerData.getResult(
+ fWriter->addTileFlag(PictureResultsWriter::kAvg);
+ fWriter->tileData(
+ &longRunningTimerData,
tiledRenderer->getNormalTimeFormat().c_str(),
TimerData::kAvg_Result,
- configName.c_str(), timerTypes, numInnerLoops);
- longRunningResult.append("\n");
- this->logProgress(longRunningResult.c_str());
+ timerTypes,
+ numInnerLoops);
}
} else {
SkAutoTDelete<BenchTimer> longRunningTimer(this->setupTimer());
@@ -246,29 +236,26 @@
SkAssertResult(longRunningTimerData.appendTimes(longRunningTimer.get()));
}
- SkString configName = fRenderer->getConfigName();
+ fWriter->tileConfig(fRenderer->getConfigName());
if (fPurgeDecodedTex) {
- configName.append(" <withPurging>");
+ fWriter->addTileFlag(PictureResultsWriter::kPurging);
}
// Beware - since the per-run-timer doesn't ever include a glFinish it can
// report a lower time then the long-running-timer
#if 0
- SkString result = perRunTimerData.getResult(timeFormat.c_str(),
- fTimerResult,
- configName.c_str(),
- timerTypes);
- result.append("\n");
-
- this->logProgress(result.c_str());
+ fWriter->tileData(
+ &perRunTimerData,
+ timeFormat.c_str(),
+ fTimerResult,
+ timerTypes);
#else
- SkString result = longRunningTimerData.getResult(timeFormat.c_str(),
- fTimerResult,
- configName.c_str(),
- timerTypes,
- numInnerLoops);
- result.append("\n");
- this->logProgress(result.c_str());
+ fWriter->tileData(
+ &longRunningTimerData,
+ timeFormat.c_str(),
+ fTimerResult,
+ timerTypes,
+ numInnerLoops);
#endif
}