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

Unified Diff: apps/benchmark/benchmark_app.cc

Issue 1347063002: Teach `benchmark.mojo` to save the collected trace file to disk. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 3 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 | « apps/benchmark/README.md ('k') | apps/benchmark/run_args.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: apps/benchmark/benchmark_app.cc
diff --git a/apps/benchmark/benchmark_app.cc b/apps/benchmark/benchmark_app.cc
index d7a5b606fbd6e165e1fe9bc176848a88d9286b84..66f742b65a6d1bade1d3e6e4af4b133c0590d248 100644
--- a/apps/benchmark/benchmark_app.cc
+++ b/apps/benchmark/benchmark_app.cc
@@ -12,6 +12,7 @@
#include "apps/benchmark/run_args.h"
#include "apps/benchmark/trace_collector_client.h"
#include "base/bind.h"
+#include "base/files/file_util.h"
#include "base/macros.h"
#include "base/memory/scoped_ptr.h"
#include "base/strings/string_split.h"
@@ -83,6 +84,17 @@ class BenchmarkApp : public mojo::ApplicationDelegate,
// TraceCollectorClient::Receiver:
void OnTraceCollected(std::string trace_data) override {
+ if (args_.write_output_file) {
+ // Write the trace file regardless of whether it can be parsed (or whether
+ // the measurements succeed), as it can be useful to debug failures.
+ base::File trace_file(
+ args_.output_file_path,
+ base::File::FLAG_CREATE_ALWAYS | base::File::FLAG_WRITE);
+ trace_file.WriteAtCurrentPos(trace_data.data(), trace_data.size());
+ printf("wrote trace file at: %s\n",
+ args_.output_file_path.value().c_str());
+ }
+
// Parse trace events.
std::vector<Event> events;
if (!GetEvents(trace_data, &events)) {
« no previous file with comments | « apps/benchmark/README.md ('k') | apps/benchmark/run_args.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698