diff options
-rw-r--r-- | bench/Benchmark.cpp | 4 | ||||
-rw-r--r-- | bench/Benchmark.h | 2 | ||||
-rw-r--r-- | bench/SKPBench.cpp | 9 | ||||
-rw-r--r-- | bench/SKPBench.h | 2 | ||||
-rw-r--r-- | bench/nanobench.cpp | 17 |
5 files changed, 24 insertions, 10 deletions
diff --git a/bench/Benchmark.cpp b/bench/Benchmark.cpp index 04223dca43..9205ba97c9 100644 --- a/bench/Benchmark.cpp +++ b/bench/Benchmark.cpp @@ -24,6 +24,10 @@ const char* Benchmark::getName() { return this->onGetName(); } +const char* Benchmark::getUniqueName() { + return this->onGetUniqueName(); +} + SkIPoint Benchmark::getSize() { return this->onGetSize(); } diff --git a/bench/Benchmark.h b/bench/Benchmark.h index 8e8eeff4f2..508d1da694 100644 --- a/bench/Benchmark.h +++ b/bench/Benchmark.h @@ -49,6 +49,7 @@ public: Benchmark(); const char* getName(); + const char* getUniqueName(); SkIPoint getSize(); enum Backend { @@ -98,6 +99,7 @@ protected: virtual void setupPaint(SkPaint* paint); virtual const char* onGetName() = 0; + virtual const char* onGetUniqueName() { return this->onGetName(); } virtual void onPreDraw() {} // Each bench should do its main work in a loop like this: // for (int i = 0; i < loops; i++) { <work here> } diff --git a/bench/SKPBench.cpp b/bench/SKPBench.cpp index 308cea6dd0..9d822d9a25 100644 --- a/bench/SKPBench.cpp +++ b/bench/SKPBench.cpp @@ -10,14 +10,19 @@ SKPBench::SKPBench(const char* name, const SkPicture* pic, const SkIRect& clip, SkScalar scale) : fPic(SkRef(pic)) , fClip(clip) - , fScale(scale) { - fName.printf("%s_%.2g", name, scale); + , fScale(scale) + , fName(name) { + fUniqueName.printf("%s_%.2g", name, scale); // Scale makes this unqiue for skiaperf.com traces. } const char* SKPBench::onGetName() { return fName.c_str(); } +const char* SKPBench::onGetUniqueName() { + return fUniqueName.c_str(); +} + bool SKPBench::isSuitableFor(Backend backend) { return backend != kNonRendering_Backend; } diff --git a/bench/SKPBench.h b/bench/SKPBench.h index 9cc9192820..0b0e008d63 100644 --- a/bench/SKPBench.h +++ b/bench/SKPBench.h @@ -21,6 +21,7 @@ public: protected: virtual const char* onGetName() SK_OVERRIDE; + virtual const char* onGetUniqueName() SK_OVERRIDE; virtual bool isSuitableFor(Backend backend) SK_OVERRIDE; virtual void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE; virtual SkIPoint onGetSize() SK_OVERRIDE; @@ -30,6 +31,7 @@ private: const SkIRect fClip; const SkScalar fScale; SkString fName; + SkString fUniqueName; typedef Benchmark INHERITED; }; diff --git a/bench/nanobench.cpp b/bench/nanobench.cpp index 20afdeb326..853492b3e0 100644 --- a/bench/nanobench.cpp +++ b/bench/nanobench.cpp @@ -163,7 +163,7 @@ static int cpu_bench(const double overhead, Benchmark* bench, SkCanvas* canvas, while (bench_plus_overhead < overhead) { if (round++ == FLAGS_maxCalibrationAttempts) { SkDebugf("WARNING: Can't estimate loops for %s (%s vs. %s); skipping.\n", - bench->getName(), HUMANIZE(bench_plus_overhead), HUMANIZE(overhead)); + bench->getUniqueName(), HUMANIZE(bench_plus_overhead), HUMANIZE(overhead)); return kFailedLoops; } bench_plus_overhead = time(1, bench, canvas, NULL); @@ -592,7 +592,7 @@ int nanobench_main() { BenchmarkStream benchStream; while (Benchmark* b = benchStream.next()) { SkAutoTDelete<Benchmark> bench(b); - if (SkCommandLineFlags::ShouldSkip(FLAGS_match, bench->getName())) { + if (SkCommandLineFlags::ShouldSkip(FLAGS_match, bench->getUniqueName())) { continue; } @@ -600,7 +600,7 @@ int nanobench_main() { create_targets(&targets, bench.get(), configs); if (!targets.isEmpty()) { - log->bench(bench->getName(), bench->getSize().fX, bench->getSize().fY); + log->bench(bench->getUniqueName(), bench->getSize().fX, bench->getSize().fY); bench->preDraw(); } for (int j = 0; j < targets.count(); j++) { @@ -617,7 +617,7 @@ int nanobench_main() { if (canvas && !FLAGS_writePath.isEmpty() && FLAGS_writePath[0]) { SkString pngFilename = SkOSPath::Join(FLAGS_writePath[0], config); - pngFilename = SkOSPath::Join(pngFilename.c_str(), bench->getName()); + pngFilename = SkOSPath::Join(pngFilename.c_str(), bench->getUniqueName()); pngFilename.append(".png"); write_canvas_png(canvas, pngFilename); } @@ -629,6 +629,7 @@ int nanobench_main() { Stats stats(samples.get(), FLAGS_samples); log->config(config); + log->configOption("name", bench->getName()); benchStream.fillCurrentOptions(log.get()); #if SK_SUPPORT_GPU if (Benchmark::kGPU_Backend == targets[j]->config.backend) { @@ -645,17 +646,17 @@ int nanobench_main() { if (targets.count() == 1) { config = ""; // Only print the config if we run the same bench on more than one. } - SkDebugf("%s\t%s\n", bench->getName(), config); + SkDebugf("%s\t%s\n", bench->getUniqueName(), config); } else if (FLAGS_verbose) { for (int i = 0; i < FLAGS_samples; i++) { SkDebugf("%s ", HUMANIZE(samples[i])); } - SkDebugf("%s\n", bench->getName()); + SkDebugf("%s\n", bench->getUniqueName()); } else if (FLAGS_quiet) { if (targets.count() == 1) { config = ""; // Only print the config if we run the same bench on more than one. } - SkDebugf("%s\t%s\t%s\n", HUMANIZE(stats.median), bench->getName(), config); + SkDebugf("%s\t%s\t%s\n", HUMANIZE(stats.median), bench->getUniqueName(), config); } else { const double stddev_percent = 100 * sqrt(stats.var) / stats.mean; SkDebugf("%4dM\t%d\t%s\t%s\t%s\t%s\t%.0f%%\t%s\t%s\t%s\n" @@ -668,7 +669,7 @@ int nanobench_main() { , stddev_percent , stats.plot.c_str() , config - , bench->getName() + , bench->getUniqueName() ); } } |