1 diff --git a/bench/ResultsWriter.h b/bench/ResultsWriter.h 2 index f56deae..69a84c7 100644 3 --- a/bench/ResultsWriter.h 4 +++ b/bench/ResultsWriter.h 5 @@ -46,6 +46,9 @@ public: 6 // Record a single test metric. 7 virtual void metric(const char name[], double ms) {} 8 9 + // Record a list of test metrics. 10 + virtual void metrics(const char name[], const SkTArray<double> &array) {} 11 + 12 // Flush to storage now please. 13 virtual void flush() {} 14 }; 15 @@ -113,6 +116,17 @@ public: 16 SkASSERT(fConfig); 17 (*fConfig)[name] = ms; 18 } 19 + void metrics(const char name[], const SkTArray<double> &array) override { 20 + // The user who wrote this feature prefers NaNs over not having results. 21 + // Hence, this ignores whether we have NaNs. 22 + SkASSERT(fConfig); 23 + Json::Value value = Json::Value(Json::arrayValue); 24 + value.resize(array.count()); 25 + for (unsigned i = 0, e = array.count(); i != e; ++i) { 26 + value[i] = array[i]; 27 + } 28 + (*fConfig)[name] = value; 29 + } 30 31 // Flush to storage now please. 32 void flush() override { 33 diff --git a/bench/nanobench.cpp b/bench/nanobench.cpp 34 index 0651302..0623d61 100644 35 --- a/bench/nanobench.cpp 36 +++ b/bench/nanobench.cpp 37 @@ -43,6 +43,7 @@ 38 #include "SkSVGDOM.h" 39 #include "SkTaskGroup.h" 40 #include "SkThreadUtils.h" 41 +#include "SkTypes.h" 42 #include "ThermalManager.h" 43 #include "SkScan.h" 44 45 @@ -1240,7 +1241,7 @@ int nanobench_main() { 46 target->setup(); 47 bench->perCanvasPreDraw(canvas); 48 49 - int maxFrameLag; 50 + int maxFrameLag = 0; 51 int loops = target->needsFrameTiming(&maxFrameLag) 52 ? setup_gpu_bench(target, bench.get(), maxFrameLag) 53 : setup_cpu_bench(overhead, target, bench.get()); 54 @@ -1290,6 +1291,7 @@ int nanobench_main() { 55 benchStream.fillCurrentOptions(log.get()); 56 target->fillOptions(log.get()); 57 log->metric("min_ms", stats.min); 58 + log->metrics("samples", samples); 59 #if SK_SUPPORT_GPU 60 if (gpuStatsDump) { 61 // dump to json, only SKPBench currently returns valid keys / values 62