From: Jens Axboe Date: Fri, 21 Feb 2014 19:50:09 +0000 (-0800) Subject: Fixup time multipliers X-Git-Tag: fio-2.1.6~20 X-Git-Url: https://git.kernel.dk/?p=fio.git;a=commitdiff_plain;h=e4668264df255e8d01680920a4e78fd4186aeff1 Fixup time multipliers Commit 74454ce4 assumed default time is in msec, when it's in reality usec. Fix that up, and also add a specific 'us' or 'usec' multiplier (of 1). Signed-off-by: Jens Axboe --- diff --git a/parse.c b/parse.c index c8bae033..5c23d91e 100644 --- a/parse.c +++ b/parse.c @@ -126,7 +126,7 @@ static unsigned long long get_mult_time(const char *str, int len) { const char *p = str; char *c; - unsigned long long mult = 1000; + unsigned long long mult = 1; /* * Go forward until we hit a non-digit, or +/- sign @@ -138,22 +138,24 @@ static unsigned long long get_mult_time(const char *str, int len) } if (!isalpha((int) *p)) - return 1000; + return mult; c = strdup(p); for (int i = 0; i < strlen(c); i++) c[i] = tolower(c[i]); - if (!strncmp("ms", c, 2)) + if (!strncmp("us", c, 2) || !strncmp("usec", c, 4)) mult = 1; - else if (!strcmp("s", c)) + else if (!strncmp("ms", c, 2) || !strncmp("msec", c, 4)) mult = 1000; + else if (!strcmp("s", c)) + mult = 1000000; else if (!strcmp("m", c)) - mult = 60 * 1000; + mult = 60 * 1000000UL; else if (!strcmp("h", c)) - mult = 60 * 60 * 1000; + mult = 60 * 60 * 1000000UL; else if (!strcmp("d", c)) - mult = 24 * 60 * 60 * 1000; + mult = 24 * 60 * 60 * 1000000UL; free(c); return mult;