Index: bench/nanobench.cpp |
diff --git a/bench/nanobench.cpp b/bench/nanobench.cpp |
index 445370741665cca3dd64c0c8cd6b41b266fe95b5..6f57bfd2e142ea1cda2935ac0a39c179910d325f 100644 |
--- a/bench/nanobench.cpp |
+++ b/bench/nanobench.cpp |
@@ -52,6 +52,8 @@ DEFINE_string(outResultsFile, "", "If given, write results here as JSON."); |
DEFINE_bool(resetGpuContext, true, "Reset the GrContext before running each bench."); |
DEFINE_int32(maxCalibrationAttempts, 3, |
"Try up to this many times to guess loops for a bench, or skip the bench."); |
+DEFINE_string(key, "", "Space-separated key/value pairs to add to JSON."); |
+DEFINE_string(gitHash, "", "Git hash to add to JSON."); |
static SkString humanize(double ms) { |
@@ -267,6 +269,13 @@ static void fill_static_options(ResultsWriter* log) { |
#endif |
} |
+#if SK_SUPPORT_GPU |
+static void fill_gpu_options(ResultsWriter* log) { |
+ // Need help, how do I get the GL version, vendor, renderer, etc? |
jcgregorio
2014/07/16 19:11:29
Open question here, how do I do this?
bsalomon
2014/07/16 19:36:29
You want to tunnel the SkGLContextHelper here (ava
jcgregorio
2014/07/17 13:11:51
Thanks!
On 2014/07/16 19:36:29, bsalomon wrote:
|
+ log->option("GL_VERSION", "4.4"); |
+} |
+#endif |
+ |
int tool_main(int argc, char** argv); |
int tool_main(int argc, char** argv) { |
SetupCrashHandler(); |
@@ -279,14 +288,26 @@ int tool_main(int argc, char** argv) { |
} |
MultiResultsWriter log; |
- SkAutoTDelete<JSONResultsWriter> json; |
- if (!FLAGS_outResultsFile.isEmpty()) { |
- json.reset(SkNEW(JSONResultsWriter(FLAGS_outResultsFile[0]))); |
+ SkAutoTDelete<NanoJSONResultsWriter> json; |
+ if (!FLAGS_outResultsFile.isEmpty() && !FLAGS_gitHash.isEmpty() ) { |
+ json.reset(SkNEW(NanoJSONResultsWriter(FLAGS_outResultsFile[0], FLAGS_gitHash[0]))); |
log.add(json.get()); |
} |
CallEnd<MultiResultsWriter> ender(log); |
+ |
+ if (1 == FLAGS_key.count() % 2) { |
+ SkDebugf("ERROR: --key must be passed with an even number of arguments"); |
+ return 1; |
+ } |
+ for (int i = 1; i < FLAGS_key.count(); i += 2) { |
+ log.key(FLAGS_key[i-1], FLAGS_key[i]); |
+ } |
fill_static_options(&log); |
+#if SK_SUPPORT_GPU |
+ fill_gpu_options(&log); |
+#endif |
+ |
const double overhead = estimate_timer_overhead(); |
SkAutoTMalloc<double> samples(FLAGS_samples); |
@@ -305,7 +326,7 @@ int tool_main(int argc, char** argv) { |
if (SkCommandLineFlags::ShouldSkip(FLAGS_match, bench->getName())) { |
continue; |
} |
- log.bench(bench->getName(), bench->getSize().fX, bench->getSize().fY); |
+ bool loggedBench = false; |
mtklein
2014/07/16 19:26:51
Why this change?
jcgregorio
2014/07/17 13:11:51
So that we only add info to the JSON file if we ac
|
SkTDArray<Target*> targets; |
create_targets(bench.get(), &targets); |
@@ -328,6 +349,10 @@ int tool_main(int argc, char** argv) { |
bench->getName(), config, humanize(overhead).c_str()); |
continue; |
} |
+ if (!loggedBench) { |
+ log.bench(bench->getName(), bench->getSize().fX, bench->getSize().fY); |
+ loggedBench = true; |
+ } |
Stats stats(samples.get(), FLAGS_samples); |
log.config(config); |