Benchmark: `--save-all-traces` argument Benchmark: Replace `--save-trace` argument by `--save-all-traces`. It outputs a .trace file per benchmark as before, but stores all traces, without filtering by the measurements defined in the benchmarks file. fixes #458 BUG= R=etiennej@chromium.org, ppi@chromium.org, qsr@chromium.org Review URL: https://codereview.chromium.org/1391013005 .
diff --git a/apps/benchmark/benchmark_app.cc b/apps/benchmark/benchmark_app.cc index bfdc299..c467d4d 100644 --- a/apps/benchmark/benchmark_app.cc +++ b/apps/benchmark/benchmark_app.cc
@@ -44,17 +44,13 @@ return; } - // Calculate a list of trace categories we want to collect: a union of all - // categories targeted in measurements. - std::set<std::string> category_set; - for (const Measurement& measurement : args_.measurements) { - std::vector<std::string> categories; - base::SplitString(measurement.target_event.categories, ',', &categories); - category_set.insert(categories.begin(), categories.end()); + // Don't compute the categories string if all categories should be traced. + std::string categories_str; + if (args_.write_output_file) { + categories_str = "*"; + } else { + categories_str = ComputeCategoriesStr(); } - std::vector<std::string> unique_categories(category_set.begin(), - category_set.end()); - std::string categories_str = JoinString(unique_categories, ','); // Connect to trace collector, which will fetch the trace events produced by // the app being benchmarked. @@ -66,12 +62,25 @@ // Start tracing the application with 1 sec of delay. base::MessageLoop::current()->PostDelayedTask( - FROM_HERE, - base::Bind(&BenchmarkApp::StartTracedApplication, - base::Unretained(this), app), + FROM_HERE, base::Bind(&BenchmarkApp::StartTracedApplication, + base::Unretained(this), app), base::TimeDelta::FromSeconds(1)); } + // Computes the string of trace categories we want to collect: a union of all + // categories targeted in measurements. + std::string ComputeCategoriesStr() { + std::set<std::string> category_set; + for (const Measurement& measurement : args_.measurements) { + std::vector<std::string> categories; + base::SplitString(measurement.target_event.categories, ',', &categories); + category_set.insert(categories.begin(), categories.end()); + } + std::vector<std::string> unique_categories(category_set.begin(), + category_set.end()); + return JoinString(unique_categories, ','); + } + void StartTracedApplication(mojo::ApplicationImpl* app) { // Record the time origin for measurements just before connecting to the app // being benchmarked.
diff --git a/mojo/devtools/common/mojo_benchmark b/mojo/devtools/common/mojo_benchmark index fc0258e..8f83c5b 100755 --- a/mojo/devtools/common/mojo_benchmark +++ b/mojo/devtools/common/mojo_benchmark
@@ -148,7 +148,7 @@ description=_DESCRIPTION) parser.add_argument('benchmark_list_file', type=file, help='a file listing benchmarks to run') - parser.add_argument('--save-traces', action='store_true', + parser.add_argument('--save-all-traces', action='store_true', help='save the traces produced by benchmarks to disk') perf_dashboard.add_argparse_server_arguments(parser) @@ -179,7 +179,7 @@ measurements = variant_spec['measurements'] output_file = None - if script_args.save_traces: + if script_args.save_all_traces: output_file = 'benchmark-%s-%s-%s.trace' % ( benchmark_name.replace(' ', '_'), variant_name.replace(' ', '_'),