From 92944f784791d7fd75d51db82df4b26003f3d427 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Tue, 23 Feb 2021 15:31:27 +0900 Subject: [PATCH] h2load: Allow unit in -D option --- src/h2load.cc | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/h2load.cc b/src/h2load.cc index 2f08cac5..6e6a9cf9 100644 --- a/src/h2load.cc +++ b/src/h2load.cc @@ -1903,7 +1903,7 @@ Options: length of the period in time. This option is ignored if the rate option is not used. The default value for this option is 1s. - -D, --duration= + -D, --duration= Specifies the main duration for the measurements in case of timing-based benchmarking. -D and -r are mutually exclusive. @@ -2199,10 +2199,9 @@ int main(int argc, char **argv) { break; } case 'D': - config.duration = strtoul(optarg, nullptr, 10); - if (config.duration == 0) { - std::cerr << "-D: the main duration for timing-based benchmarking " - << "must be positive." << std::endl; + config.duration = util::parse_duration_with_unit(optarg); + if (!std::isfinite(config.duration)) { + std::cerr << "-D: value error " << optarg << std::endl; exit(EXIT_FAILURE); } break;