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

Unified Diff: apps/benchmark/run_args.cc

Issue 1380023005: benchmark.mojo: add time_between measurement type. (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/measurements_unittest.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: apps/benchmark/run_args.cc
diff --git a/apps/benchmark/run_args.cc b/apps/benchmark/run_args.cc
index aa21f9fd6e6658be05d766312e8a949f60bd9ce1..d8037b91423d7cf25da641e2a27663963d7ebba3 100644
--- a/apps/benchmark/run_args.cc
+++ b/apps/benchmark/run_args.cc
@@ -14,28 +14,50 @@
namespace benchmark {
namespace {
+bool CheckMeasurementFormat(const std::string& type,
+ int required_args,
+ int provided_args) {
+ if (required_args != provided_args) {
+ LOG(ERROR) << "Could not parse a measurement of type " << type
+ << ", expected " << required_args << " while " << provided_args
+ << " were provided";
+ return false;
+ }
+ return true;
+}
+
bool GetMeasurement(const std::string& measurement_spec, Measurement* result) {
// Measurements are described in the format:
// <measurement type>/<event category>/<event name>.
std::vector<std::string> parts;
base::SplitString(measurement_spec, '/', &parts);
- if (parts.size() != 3) {
+ if (parts.size() < 1) {
LOG(ERROR) << "Could not parse the measurement description: "
<< measurement_spec;
return false;
}
if (parts[0] == "time_until") {
- result->type = MeasurementType::TIME_UNTIL;
+ if (!CheckMeasurementFormat(parts[0], 3, parts.size()))
+ return false;
+ *result =
+ Measurement(MeasurementType::TIME_UNTIL, EventSpec(parts[1], parts[2]));
+ } else if (parts[0] == "time_between") {
+ if (!CheckMeasurementFormat(parts[0], 5, parts.size()))
+ return false;
+ *result = Measurement(MeasurementType::TIME_BETWEEN,
+ EventSpec(parts[1], parts[2]),
+ EventSpec(parts[3], parts[4]));
} else if (parts[0] == "avg_duration") {
- result->type = MeasurementType::AVG_DURATION;
+ if (!CheckMeasurementFormat(parts[0], 3, parts.size()))
+ return false;
+ *result = Measurement(MeasurementType::AVG_DURATION,
+ EventSpec(parts[1], parts[2]));
} else {
LOG(ERROR) << "Could not recognize the measurement type: " << parts[0];
return false;
}
- result->target_event.categories = parts[1];
- result->target_event.name = parts[2];
result->spec = measurement_spec;
return true;
}
« no previous file with comments | « apps/benchmark/measurements_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698