Collect perf data in normal mode to get build IDs
BUG=chromium:361726
TEST=unit tests pass
Change-Id: I3540dba323e0621d38605ce07b19dd53500c7719
Signed-off-by: Simon Que <sque@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/193861
Reviewed-by: Ahmad Sharif <asharif@chromium.org>
diff --git a/perf_recorder.cc b/perf_recorder.cc
index 0c4a89d..e3812b4 100644
--- a/perf_recorder.cc
+++ b/perf_recorder.cc
@@ -10,6 +10,7 @@
#include "perf_recorder.h"
#include "perf_serializer.h"
#include "quipper_string.h"
+#include "scoped_temp_path.h"
#include "utils.h"
namespace quipper {
@@ -24,10 +25,14 @@
const string& perf_command,
const int time,
quipper::PerfDataProto* perf_data) {
- string full_perf_command = perf_command + " -o - -- " + GetSleepCommand(time);
+ ScopedTempFile output_file;
+ string full_perf_command = perf_command + " -o " + output_file.path() +
+ " -- " + GetSleepCommand(time);
- std::vector<char> raw_perf_data;
- RunCommandAndGetStdout(full_perf_command, &raw_perf_data);
+ // The perf command writes the output to a file. |stdout_data| is just a dummy
+ // container so we have something to pass to RunCommandAndGetStdout().
+ std::vector<char> stdout_data;
+ RunCommandAndGetStdout(full_perf_command, &stdout_data);
// Now convert it into a protobuf.
PerfSerializer perf_serializer;
@@ -39,8 +44,7 @@
perf_serializer.set_options(options);
- return (perf_serializer.ReadFromVector(raw_perf_data) &&
- perf_serializer.Serialize(perf_data));
+ return perf_serializer.SerializeFromFile(output_file.path(), perf_data);
}
} // namespace quipper
diff --git a/perf_recorder_test.cc b/perf_recorder_test.cc
index 3937e10..9f29b55 100644
--- a/perf_recorder_test.cc
+++ b/perf_recorder_test.cc
@@ -24,6 +24,7 @@
EXPECT_TRUE(perf_recorder.RecordAndConvertToProtobuf(perf_command_line,
1,
&perf_data_proto));
+ EXPECT_GT(perf_data_proto.build_ids_size(), 0);
}
} // namespace quipper
diff --git a/scoped_temp_path.cc b/scoped_temp_path.cc
index a424199..3be0c4e 100644
--- a/scoped_temp_path.cc
+++ b/scoped_temp_path.cc
@@ -15,7 +15,7 @@
// Temporary paths follow this format, with the X's replaced by letters or
// digits. This cannot be defined as a const variable because mkstemp() and
// mkdtemp() requires an initialized but variable string as an argument.
-#define TEMP_PATH_STRING "/tmp/quipper.XXXXXXXX"
+#define TEMP_PATH_STRING "/tmp/quipper.XXXXXX"
namespace quipper {