h2load: Allow unit in -D option

This commit is contained in:
Tatsuhiro Tsujikawa 2021-02-23 15:31:27 +09:00
parent 276792a812
commit 92944f7847
1 changed files with 4 additions and 5 deletions

View File

@ -1903,7 +1903,7 @@ Options:
length of the period in time. This option is ignored if length of the period in time. This option is ignored if
the rate option is not used. The default value for this the rate option is not used. The default value for this
option is 1s. option is 1s.
-D, --duration=<N> -D, --duration=<DURATION>
Specifies the main duration for the measurements in case Specifies the main duration for the measurements in case
of timing-based benchmarking. -D and -r are mutually of timing-based benchmarking. -D and -r are mutually
exclusive. exclusive.
@ -2199,10 +2199,9 @@ int main(int argc, char **argv) {
break; break;
} }
case 'D': case 'D':
config.duration = strtoul(optarg, nullptr, 10); config.duration = util::parse_duration_with_unit(optarg);
if (config.duration == 0) { if (!std::isfinite(config.duration)) {
std::cerr << "-D: the main duration for timing-based benchmarking " std::cerr << "-D: value error " << optarg << std::endl;
<< "must be positive." << std::endl;
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
break; break;