Reland https://codereview.chromium.org/286903025
BUG=skia:
R=bensong@google.com, epoger@google.com
Author: kelvinly@google.com
Review URL: https://codereview.chromium.org/304613002
git-svn-id: http://skia.googlecode.com/svn/trunk@14966 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/tools/bench_pictures_main.cpp b/tools/bench_pictures_main.cpp
index 5ff519c..b79dfed 100644
--- a/tools/bench_pictures_main.cpp
+++ b/tools/bench_pictures_main.cpp
@@ -12,6 +12,7 @@
#include "PictureRenderingFlags.h"
#include "SkBenchLogger.h"
#include "SkCommandLineFlags.h"
+#include "SkData.h"
#include "SkDiscardableMemoryPool.h"
#include "SkGraphics.h"
#include "SkImageDecoder.h"
@@ -20,8 +21,11 @@
#include "SkPicture.h"
#include "SkStream.h"
#include "picture_utils.h"
+#include "PictureResultsWriter.h"
SkBenchLogger gLogger;
+PictureResultsLoggerWriter gLogWriter(&gLogger);
+PictureResultsMultiWriter gWriter;
// Flags used by this file, in alphabetical order.
DEFINE_bool(countRAM, false, "Count the RAM used for bitmap pixels in each skp file");
@@ -35,6 +39,9 @@
"Specific flags are listed above.");
DEFINE_string(logFile, "", "Destination for writing log output, in addition to stdout.");
DEFINE_bool(logPerIter, false, "Log each repeat timer instead of mean.");
+#ifdef SK_BUILD_JSON_WRITER
+DEFINE_string(jsonLog, "", "Destination for writing JSON data.");
+#endif
DEFINE_bool(min, false, "Print the minimum times (instead of average).");
DECLARE_int32(multi);
DECLARE_string(readPath);
@@ -187,10 +194,7 @@
SkString filename;
sk_tools::get_basename(&filename, inputPath);
- SkString result;
- result.printf("running bench [%i %i] %s ", picture->width(), picture->height(),
- filename.c_str());
- gLogger.logProgress(result);
+ gWriter.bench(filename.c_str(), picture->width(), picture->height());
benchmark.run(picture);
@@ -360,7 +364,7 @@
}
benchmark->setRenderer(renderer);
benchmark->setRepeats(FLAGS_repeat);
- benchmark->setLogger(&gLogger);
+ benchmark->setWriter(&gWriter);
}
static int process_input(const char* input,
@@ -417,6 +421,16 @@
}
}
+#ifdef SK_BUILD_JSON_WRITER
+ SkAutoTDelete<PictureJSONResultsWriter> jsonWriter;
+ if (FLAGS_jsonLog.count() == 1) {
+ jsonWriter.reset(SkNEW(PictureJSONResultsWriter(FLAGS_jsonLog[0])));
+ gWriter.add(jsonWriter.get());
+ }
+
+#endif
+ gWriter.add(&gLogWriter);
+
#if SK_ENABLE_INST_COUNT
gPrintInstCount = true;
@@ -444,6 +458,7 @@
(double) gTotalCacheHits / (gTotalCacheHits + gTotalCacheMisses));
}
#endif
+ gWriter.end();
return 0;
}