| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "apps/benchmark/run_args.h" | 5 #include "apps/benchmark/run_args.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/strings/string_number_conversions.h" | 11 #include "base/strings/string_number_conversions.h" |
| 12 #include "base/strings/string_split.h" | 12 #include "base/strings/string_split.h" |
| 13 #include "base/strings/string_util.h" |
| 13 | 14 |
| 14 namespace benchmark { | 15 namespace benchmark { |
| 15 namespace { | 16 namespace { |
| 16 | 17 |
| 17 bool CheckMeasurementFormat(const std::string& type, | 18 bool CheckMeasurementFormat(const std::string& type, |
| 18 int required_args, | 19 int required_args, |
| 19 int provided_args) { | 20 int provided_args) { |
| 20 if (required_args != provided_args) { | 21 if (required_args != provided_args) { |
| 21 LOG(ERROR) << "Could not parse a measurement of type " << type | 22 LOG(ERROR) << "Could not parse a measurement of type " << type |
| 22 << ", expected " << required_args << " while " << provided_args | 23 << ", expected " << required_args << " while " << provided_args |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 if (command_line.HasSwitch("trace-output")) { | 109 if (command_line.HasSwitch("trace-output")) { |
| 109 result->write_output_file = true; | 110 result->write_output_file = true; |
| 110 result->output_file_path = | 111 result->output_file_path = |
| 111 base::FilePath(command_line.GetSwitchValueASCII("trace-output")); | 112 base::FilePath(command_line.GetSwitchValueASCII("trace-output")); |
| 112 } | 113 } |
| 113 | 114 |
| 114 // All regular arguments (not switches, ie. not preceded by "--") describe | 115 // All regular arguments (not switches, ie. not preceded by "--") describe |
| 115 // measurements. | 116 // measurements. |
| 116 for (const std::string& measurement_spec : command_line.GetArgs()) { | 117 for (const std::string& measurement_spec : command_line.GetArgs()) { |
| 117 Measurement measurement; | 118 Measurement measurement; |
| 118 if (!GetMeasurement(measurement_spec, &measurement)) { | 119 std::string unquoted_measurement_spec; |
| 120 base::TrimString(measurement_spec, "'\"", &unquoted_measurement_spec); |
| 121 if (!GetMeasurement(unquoted_measurement_spec, &measurement)) { |
| 119 return false; | 122 return false; |
| 120 } | 123 } |
| 121 result->measurements.push_back(measurement); | 124 result->measurements.push_back(measurement); |
| 122 } | 125 } |
| 123 | 126 |
| 124 return true; | 127 return true; |
| 125 } | 128 } |
| 126 | 129 |
| 127 } // namespace benchmark | 130 } // namespace benchmark |
| OLD | NEW |