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

Unified Diff: bench/nanobench.cpp

Issue 438683002: nanobench: support GMs-as-benches (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: GM_ 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 | « bench/GMBench.cpp ('k') | 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 07ff0dd2b029677369f36286b8f9d54990af8864..742a6ed11d65d7450c07d5c22aa83a96a3845903 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);
« no previous file with comments | « bench/GMBench.cpp ('k') | gyp/bench.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698