diff options
author | mtklein <mtklein@chromium.org> | 2014-10-14 08:40:43 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-10-14 08:40:43 -0700 |
commit | e070c2bf54c451f0126d4ffb3a48bffe1fbfa437 (patch) | |
tree | cf7fc2fe14f08726e2f7b8819ab40b752dd4733e /bench | |
parent | b2d77e4d7458145ef4825c28323d9fbbb6b003ac (diff) |
nanobench: flush after recording every Nth data point.
Got to keep our precious data in event of a crash.
With --flushEvery 10 I'm not seeing this cost any wall time.
BUG=skia:
Review URL: https://codereview.chromium.org/653083003
Diffstat (limited to 'bench')
-rw-r--r-- | bench/ResultsWriter.h | 14 | ||||
-rw-r--r-- | bench/nanobench.cpp | 5 |
2 files changed, 16 insertions, 3 deletions
diff --git a/bench/ResultsWriter.h b/bench/ResultsWriter.h index f17bce3d93..b8d97075a1 100644 --- a/bench/ResultsWriter.h +++ b/bench/ResultsWriter.h @@ -45,6 +45,9 @@ public: // Record a single test metric. virtual void timer(const char name[], double ms) {} + + // Flush to storage now please. + virtual void flush() {} }; /** @@ -79,9 +82,7 @@ public: , fConfig(NULL) {} ~NanoJSONResultsWriter() { - SkFILEWStream stream(fFilename.c_str()); - stream.writeText(Json::StyledWriter().write(fRoot).c_str()); - stream.flush(); + this->flush(); } // Added under "key". @@ -113,6 +114,13 @@ public: (*fConfig)[name] = ms; } + // Flush to storage now please. + virtual void flush() { + SkFILEWStream stream(fFilename.c_str()); + stream.writeText(Json::StyledWriter().write(fRoot).c_str()); + stream.flush(); + } + private: SkString fFilename; Json::Value fRoot; diff --git a/bench/nanobench.cpp b/bench/nanobench.cpp index d06d75358d..250f438d6a 100644 --- a/bench/nanobench.cpp +++ b/bench/nanobench.cpp @@ -70,6 +70,7 @@ DEFINE_int32(maxLoops, 1000000, "Never run a bench more times than this."); DEFINE_string(clip, "0,0,1000,1000", "Clip for SKPs."); DEFINE_string(scales, "1.0", "Space-separated scales for SKPs."); DEFINE_bool(bbh, true, "Build a BBH for SKPs?"); +DEFINE_int32(flushEvery, 10, "Flush --outResultsFile every Nth run."); static SkString humanize(double ms) { if (FLAGS_verbose) return SkStringPrintf("%llu", (uint64_t)(ms*1e6)); @@ -628,6 +629,7 @@ int nanobench_main() { SkTDArray<Config> configs; create_configs(&configs); + int runs = 0; BenchmarkStream benchStream; while (Benchmark* b = benchStream.next()) { SkAutoTDelete<Benchmark> bench(b); @@ -680,6 +682,9 @@ int nanobench_main() { log->timer("mean_ms", stats.mean); log->timer("max_ms", stats.max); log->timer("stddev_ms", sqrt(stats.var)); + if (runs++ % FLAGS_flushEvery == 0) { + log->flush(); + } if (kAutoTuneLoops != FLAGS_loops) { if (targets.count() == 1) { |