diff options
author | mtklein <mtklein@chromium.org> | 2014-07-31 12:13:48 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-07-31 12:13:48 -0700 |
commit | e714e75c725c987fe682a1f5473224fe3e80380d (patch) | |
tree | ba713f7e0a5a09b3aa2a2cd93cf4a53dabe63ea6 | |
parent | e681c2a5061022511fbdf93319fb4b6043a5fb58 (diff) |
nanobench: support GMs-as-benches
BUG=skia:
R=jcgregorio@google.com, mtklein@google.com
Author: mtklein@chromium.org
Review URL: https://codereview.chromium.org/438683002
-rw-r--r-- | bench/GMBench.cpp | 2 | ||||
-rw-r--r-- | bench/nanobench.cpp | 42 | ||||
-rw-r--r-- | gyp/bench.gyp | 8 |
3 files changed, 43 insertions, 9 deletions
diff --git a/bench/GMBench.cpp b/bench/GMBench.cpp index 41a8e8c5f4..dbd1d7b24a 100644 --- a/bench/GMBench.cpp +++ b/bench/GMBench.cpp @@ -8,7 +8,7 @@ #include "GMBench.h" GMBench::GMBench(skiagm::GM* gm) : fGM(gm) { - fName.printf("GM:%s", gm->getName()); + fName.printf("GM_%s", gm->getName()); } GMBench::~GMBench() { delete fGM; } diff --git a/bench/nanobench.cpp b/bench/nanobench.cpp index 07ff0dd2b0..742a6ed11d 100644 --- a/bench/nanobench.cpp +++ b/bench/nanobench.cpp @@ -9,6 +9,7 @@ #include "Benchmark.h" #include "CrashHandler.h" +#include "GMBench.h" #include "ResultsWriter.h" #include "Stats.h" #include "Timer.h" @@ -239,7 +240,7 @@ static bool is_gpu_config_allowed(const char* name, GrContextFactory::GLContextT #define kBogusGLContextType GrContextFactory::kNative_GLContextType #else #define kBogusGLContextType 0 -#endif +#endif // Append all configs that are enabled and supported. static void create_configs(SkTDArray<Config>* configs) { @@ -248,7 +249,7 @@ static void create_configs(SkTDArray<Config>* configs) { Config config = { #name, Benchmark::backend, color, alpha, 0, kBogusGLContextType }; \ configs->push(config); \ } - + if (FLAGS_cpu) { CPU_CONFIG(nonrendering, kNonRendering_Backend, kUnknown_SkColorType, kUnpremul_SkAlphaType) CPU_CONFIG(8888, kRaster_Backend, kN32_SkColorType, kPremul_SkAlphaType) @@ -267,7 +268,7 @@ static void create_configs(SkTDArray<Config>* configs) { GrContextFactory::ctxType }; \ configs->push(config); \ } - + if (FLAGS_gpu) { GPU_CONFIG(gpu, kNative_GLContextType, 0) GPU_CONFIG(msaa4, kNative_GLContextType, 4) @@ -319,7 +320,7 @@ static void create_targets(SkTDArray<Target*>* targets, Benchmark* b, if (Target* t = is_enabled(b, configs[i])) { targets->push(t); } - + } } @@ -354,6 +355,32 @@ static void fill_gpu_options(ResultsWriter* log, SkGLContextHelper* ctx) { } #endif +class BenchmarkStream { +public: + BenchmarkStream() : fBenches(BenchRegistry::Head()) , fGMs(skiagm::GMRegistry::Head()) {} + + Benchmark* next(const char** sourceType) { + if (fBenches) { + Benchmark* bench = fBenches->factory()(NULL); + fBenches = fBenches->next(); + *sourceType = "bench"; + return bench; + } + while (fGMs) { + SkAutoTDelete<skiagm::GM> gm(fGMs->factory()(NULL)); + fGMs = fGMs->next(); + if (gm->getFlags() & skiagm::GM::kAsBench_Flag) { + *sourceType = "gm"; + return SkNEW_ARGS(GMBench, (gm.detach())); + } + } + return NULL; + } +private: + const BenchRegistry* fBenches; + const skiagm::GMRegistry* fGMs; +}; + int nanobench_main(); int nanobench_main() { SetupCrashHandler(); @@ -400,8 +427,10 @@ int nanobench_main() { SkTDArray<Config> configs; create_configs(&configs); - for (const BenchRegistry* r = BenchRegistry::Head(); r != NULL; r = r->next()) { - SkAutoTDelete<Benchmark> bench(r->factory()(NULL)); + BenchmarkStream benches; + const char* sourceType; + while (Benchmark* b = benches.next(&sourceType)) { + SkAutoTDelete<Benchmark> bench(b); if (SkCommandLineFlags::ShouldSkip(FLAGS_match, bench->getName())) { continue; } @@ -433,6 +462,7 @@ int nanobench_main() { Stats stats(samples.get(), FLAGS_samples); log.config(config); + log.configOption("source_type", sourceType); #if SK_SUPPORT_GPU if (Benchmark::kGPU_Backend == targets[j]->config.backend) { fill_gpu_options(&log, targets[j]->gl); diff --git a/gyp/bench.gyp b/gyp/bench.gyp index ad026a6439..d6275905de 100644 --- a/gyp/bench.gyp +++ b/gyp/bench.gyp @@ -37,10 +37,14 @@ 'target_name': 'nanobench', 'type': 'executable', 'sources': [ - '../bench/nanobench.cpp', + '../bench/GMBench.cpp', '../bench/ResultsWriter.cpp', + '../bench/nanobench.cpp', + ], + 'includes': [ + 'bench.gypi', + 'gmslides.gypi', ], - 'includes': [ 'bench.gypi' ], 'dependencies': [ 'flags.gyp:flags_common', 'jsoncpp.gyp:jsoncpp', |