Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(71)

Unified Diff: tools/kilobench/kilobench.cpp

Issue 1588733006: Simple change to add json results writer to kilobench (Closed) Base URL: https://skia.googlesource.com/skia.git@kilobench-2-setupcanvas
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/kilobench/kilobench.cpp
diff --git a/tools/kilobench/kilobench.cpp b/tools/kilobench/kilobench.cpp
index 438e582324fb2e8c97f1da061e7d9a3f8760d870..940e3cc213a0b2696de0c5b63a364c4bd7e1c2e6 100644
--- a/tools/kilobench/kilobench.cpp
+++ b/tools/kilobench/kilobench.cpp
@@ -62,6 +62,11 @@ DEFINE_int32(maxLoops, 1000000, "Never run a bench more times than this.");
DEFINE_int32(loops, kDefaultLoops, loops_help_txt().c_str());
DEFINE_double(gpuMs, 5, "Target bench time in millseconds for GPU.");
DEFINE_string2(writePath, w, "", "If set, write bitmaps here as .pngs.");
+DEFINE_string(outResultsFile, "", "If given, write results here as JSON.");
+DEFINE_string(key, "",
+ "Space-separated key/value pairs to add to JSON identifying this builder.");
+DEFINE_string(properties, "",
+ "Space-separated key/value pairs to add to JSON identifying this run.");
namespace kilobench {
class BenchmarkStream {
@@ -327,7 +332,7 @@ static SkString humanize(double ms) {
}
#define HUMANIZE(ms) humanize(ms).c_str()
-void benchmark_inner_loop(Benchmark* bench, GrContextFactory* ctxFactory) {
+void benchmark_inner_loop(Benchmark* bench, GrContextFactory* ctxFactory, ResultsWriter* log) {
SkTArray<double> samples;
GPUTarget target;
SkAssertResult(target.init(bench, ctxFactory, false,
@@ -369,16 +374,48 @@ void benchmark_inner_loop(Benchmark* bench, GrContextFactory* ctxFactory) {
pngFilename.append(".png");
write_canvas_png(&target, pngFilename);
}
+
+ log->config("gpu");
+ log->configOption("name", bench->getName());
+ log->metric("min_ms", stats.min);
+ log->metric("median_ms", stats.median);
}
} // namespace kilobench
+static ResultsWriter* setup_log() {
+ ResultsWriter* log;
+ if (!FLAGS_outResultsFile.isEmpty()) {
+ log = new NanoJSONResultsWriter(FLAGS_outResultsFile[0]);
+ } else {
+ log = new ResultsWriter;
+ }
+
+ if (1 == FLAGS_properties.count() % 2) {
+ SkDebugf("ERROR: --properties must be passed with an even number of arguments.\n");
+ return 1;
+ }
+ for (int i = 1; i < FLAGS_properties.count(); i += 2) {
+ log->property(FLAGS_properties[i-1], FLAGS_properties[i]);
+ }
+
+ if (1 == FLAGS_key.count() % 2) {
+ SkDebugf("ERROR: --key must be passed with an even number of arguments.\n");
+ return 1;
+ }
+ for (int i = 1; i < FLAGS_key.count(); i += 2) {
+ log->key(FLAGS_key[i-1], FLAGS_key[i]);
+ }
+ return log;
+}
int kilobench_main() {
SkAutoTDelete<GrContextFactory> ctxFactory;
GrContextOptions grContextOpts;
ctxFactory.reset(new GrContextFactory(grContextOpts));
+ SkAutoTDelete<ResultsWriter> log(setup_log());
+
kilobench::BenchmarkStream benchStream;
SkDebugf("loops\tmin\tmedian\tmean\tmax\tstddev\t%-*s\tconfig\tbench\n",
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698