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

Unified Diff: bench/nanobench.cpp

Issue 390933002: nanobench: support --outResultsFile (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 5 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 | gyp/bench.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: bench/nanobench.cpp
diff --git a/bench/nanobench.cpp b/bench/nanobench.cpp
index 3f34740b6963cf993672d6ff92707fa05d205eab..cc9896ea1bb6e01ea68537e9e4d019971395f572 100644
--- a/bench/nanobench.cpp
+++ b/bench/nanobench.cpp
@@ -9,6 +9,7 @@
#include "Benchmark.h"
#include "CrashHandler.h"
+#include "ResultsWriter.h"
#include "Stats.h"
#include "Timer.h"
@@ -41,6 +42,8 @@ DEFINE_int32(gpuFrameLag, 5, "Overestimate of maximum number of frames GPU allow
DEFINE_bool(cpu, true, "Master switch for CPU-bound work.");
DEFINE_bool(gpu, true, "Master switch for GPU-bound work.");
+DEFINE_string(outResultsFile, "", "If given, write results here as JSON.");
+
static SkString humanize(double ms) {
if (ms > 1e+3) return SkStringPrintf("%.3gs", ms/1e3);
@@ -224,12 +227,40 @@ static void create_targets(Benchmark* bench, SkTDArray<Target*>* targets) {
#endif
}
+static void fill_static_options(ResultsWriter* log) {
+#if defined(SK_BUILD_FOR_WIN32)
+ log->option("system", "WIN32");
+#elif defined(SK_BUILD_FOR_MAC)
+ log->option("system", "MAC");
+#elif defined(SK_BUILD_FOR_ANDROID)
+ log->option("system", "ANDROID");
+#elif defined(SK_BUILD_FOR_UNIX)
+ log->option("system", "UNIX");
+#else
+ log->option("system", "other");
+#endif
+#if defined(SK_DEBUG)
+ log->option("build", "DEBUG");
+#else
+ log->option("build", "RELEASE");
+#endif
+}
+
int tool_main(int argc, char** argv);
int tool_main(int argc, char** argv) {
SetupCrashHandler();
SkAutoGraphics ag;
SkCommandLineFlags::Parse(argc, argv);
+ MultiResultsWriter log;
+ SkAutoTDelete<JSONResultsWriter> json;
+ if (!FLAGS_outResultsFile.isEmpty()) {
+ json.reset(SkNEW(JSONResultsWriter(FLAGS_outResultsFile[0])));
+ log.add(json.get());
+ }
+ CallEnd<MultiResultsWriter> ender(log);
+ fill_static_options(&log);
+
const double overhead = estimate_timer_overhead();
SkAutoTMalloc<double> samples(FLAGS_samples);
@@ -246,6 +277,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);
SkTDArray<Target*> targets;
create_targets(bench.get(), &targets);
@@ -265,6 +297,14 @@ int tool_main(int argc, char** argv) {
Stats stats(samples.get(), FLAGS_samples);
const char* config = targets[j]->config;
+
+ log.config(config);
+ log.timer("min_ms", stats.min);
+ log.timer("median_ms", stats.median);
+ log.timer("mean_ms", stats.mean);
+ log.timer("max_ms", stats.max);
+ log.timer("stddev_ms", sqrt(stats.var));
+
if (FLAGS_verbose) {
for (int i = 0; i < FLAGS_samples; i++) {
SkDebugf("%s ", humanize(samples[i]).c_str());
« no previous file with comments | « no previous file | gyp/bench.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698