* [patch 3/9] fio: allow milliseconds on all time specifiers
@ 2014-02-20 13:20 ehrhardt
2014-02-21 19:49 ` Jens Axboe
0 siblings, 1 reply; 3+ messages in thread
From: ehrhardt @ 2014-02-20 13:20 UTC (permalink / raw)
To: fio; +Cc: oberpar, Christian Ehrhardt
*Resend with hopefully non mangled patches*
References: <20140220131958.965092001@linux.vnet.ibm.com>
Content-Disposition: inline; filename=support-milliseconds.diff
From: Christian Ehrhardt <ehrhardt@linux.vnet.ibm.com>
This patch allows all time specifiers to be specified down to milliseconds.
Default will stay seconds for compatibility with old configs.
It also adds documentation to the existing time units day, hour and minute.
Signed-off-by: Christian Ehrhardt <ehrhardt@linux.vnet.ibm.com>
---
[diffstat]
backend.c | 4 ++--
eta.c | 14 ++++++++------
fio.1 | 16 ++++++++++------
parse.c | 48 ++++++++++++++++++++++++++++++++++--------------
time.c | 2 +-
5 files changed, 55 insertions(+), 29 deletions(-)
[diff]
--- a/backend.c
+++ b/backend.c
@@ -346,7 +346,7 @@ static inline int runtime_exceeded(struc
return 0;
if (!td->o.timeout)
return 0;
- if (mtime_since(&td->epoch, t) >= td->o.timeout * 1000)
+ if (mtime_since(&td->epoch, t) >= td->o.timeout )
return 1;
return 0;
@@ -1783,7 +1783,7 @@ static void run_threads(void)
if (td->o.start_delay) {
spent = mtime_since_genesis();
- if (td->o.start_delay * 1000 > spent)
+ if (td->o.start_delay > spent)
continue;
}
--- a/eta.c
+++ b/eta.c
@@ -174,7 +174,8 @@ static int thread_eta(struct thread_data
perc = 1.0;
if (td->o.time_based) {
- perc_t = (double) elapsed / (double) td->o.timeout;
+ perc_t = (double) elapsed /
+ (double) (td->o.timeout / 1000);
if (perc_t < perc)
perc = perc_t;
}
@@ -182,8 +183,9 @@ static int thread_eta(struct thread_data
eta_sec = (unsigned long) (elapsed * (1.0 / perc)) - elapsed;
if (td->o.timeout &&
- eta_sec > (td->o.timeout + done_secs - elapsed))
- eta_sec = td->o.timeout + done_secs - elapsed;
+ eta_sec > ( (td->o.timeout / 1000) + done_secs - elapsed))
+ eta_sec = (td->o.timeout / 1000) + done_secs
+ - elapsed;
} else if (td->runstate == TD_NOT_CREATED || td->runstate == TD_CREATED
|| td->runstate == TD_INITIALIZED
|| td->runstate == TD_SETTING_UP
@@ -197,8 +199,8 @@ static int thread_eta(struct thread_data
* if given, otherwise assume it'll run at the specified rate.
*/
if (td->o.timeout) {
- t_eta = td->o.timeout + td->o.start_delay +
- td->o.ramp_time;
+ t_eta = (td->o.timeout + td->o.start_delay +
+ td->o.ramp_time ) / 1000;
if (in_ramp_time(td)) {
unsigned long ramp_left;
@@ -212,7 +214,7 @@ static int thread_eta(struct thread_data
rate_bytes = ddir_rw_sum(td->o.rate);
if (rate_bytes) {
r_eta = (bytes_total / 1024) / rate_bytes;
- r_eta += td->o.start_delay;
+ r_eta += td->o.start_delay / 1000;
}
if (r_eta && t_eta)
--- a/fio.1
+++ b/fio.1
@@ -121,12 +121,16 @@ String: a sequence of alphanumeric chara
SI integer: a whole number, possibly containing a suffix denoting the base unit
of the value. Accepted suffixes are `k', 'M', 'G', 'T', and 'P', denoting
kilo (1024), mega (1024^2), giga (1024^3), tera (1024^4), and peta (1024^5)
-respectively. The suffix is not case sensitive. If prefixed with '0x', the
-value is assumed to be base 16 (hexadecimal). A suffix may include a trailing 'b',
-for instance 'kb' is identical to 'k'. You can specify a base 10 value
-by using 'KiB', 'MiB', 'GiB', etc. This is useful for disk drives where
-values are often given in base 10 values. Specifying '30GiB' will get you
-30*1000^3 bytes.
+respectively. If prefixed with '0x', the value is assumed to be base 16
+(hexadecimal). A suffix may include a trailing 'b', for instance 'kb' is
+identical to 'k'. You can specify a base 10 value by using 'KiB', 'MiB','GiB',
+etc. This is useful for disk drives where values are often given in base 10
+values. Specifying '30GiB' will get you 30*1000^3 bytes.
+When specifying times the default suffix meaning changes, still denoting the
+base unit of the value, but accepted suffixes are 'D' (days), 'H' (hours), 'M'
+(minutes), 'S' Seconds, 'ms' milli seconds. Time values without a unit specify
+seconds.
+The suffixes are not case sensitive.
.TP
.I bool
Boolean: a true or false value. `0' denotes false, `1' denotes true.
--- a/parse.c
+++ b/parse.c
@@ -122,21 +122,41 @@ static void show_option_help(struct fio_
show_option_values(o);
}
-static unsigned long get_mult_time(char c)
+static unsigned long long get_mult_time(const char *str, int len)
{
- switch (c) {
- case 'm':
- case 'M':
- return 60;
- case 'h':
- case 'H':
- return 60 * 60;
- case 'd':
- case 'D':
- return 24 * 60 * 60;
- default:
- return 1;
+ const char *p = str;
+ char *c;
+ unsigned long long mult = 1000;
+
+ /*
+ * Go forward until we hit a non-digit, or +/- sign
+ */
+ while ((p - str) <= len) {
+ if (!isdigit((int) *p) && (*p != '+') && (*p != '-'))
+ break;
+ p++;
}
+
+ if (!isalpha((int) *p))
+ return 1000;
+
+ c = strdup(p);
+ for (int i = 0; i < strlen(c); i++)
+ c[i] = tolower(c[i]);
+
+ if (!strncmp("ms", c, 2))
+ mult = 1;
+ else if (!strcmp("s", c))
+ mult = 1000;
+ else if (!strcmp("m", c))
+ mult = 60 * 1000;
+ else if (!strcmp("h", c))
+ mult = 60 * 60 * 1000;
+ else if (!strcmp("d", c))
+ mult = 24 * 60 * 60 * 1000;
+
+ free(c);
+ return mult;
}
static int is_separator(char c)
@@ -275,7 +295,7 @@ int str_to_decimal(const char *str, long
else
*val *= mult;
} else
- *val *= get_mult_time(str[len - 1]);
+ *val *= get_mult_time(str, len);
return 0;
}
--- a/time.c
+++ b/time.c
@@ -71,7 +71,7 @@ int ramp_time_over(struct thread_data *t
return 1;
fio_gettime(&tv, NULL);
- if (mtime_since(&td->epoch, &tv) >= td->o.ramp_time * 1000) {
+ if (mtime_since(&td->epoch, &tv) >= td->o.ramp_time ) {
td->ramp_time_over = 1;
reset_all_stats(td);
td_set_runstate(td, TD_RAMP);
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [patch 3/9] fio: allow milliseconds on all time specifiers
2014-02-20 13:20 [patch 3/9] fio: allow milliseconds on all time specifiers ehrhardt
@ 2014-02-21 19:49 ` Jens Axboe
0 siblings, 0 replies; 3+ messages in thread
From: Jens Axboe @ 2014-02-21 19:49 UTC (permalink / raw)
To: ehrhardt; +Cc: fio, oberpar
On Thu, Feb 20 2014, ehrhardt@linux.vnet.ibm.com wrote:
> From: Christian Ehrhardt <ehrhardt@linux.vnet.ibm.com>
>
> This patch allows all time specifiers to be specified down to milliseconds.
> Default will stay seconds for compatibility with old configs.
>
> It also adds documentation to the existing time units day, hour and minute.
THis breaks default delays being in usec, it's not in msec. So if you
had some time set before on options that weren't specifically seconds,
it now would be msec instead of usec. I will commit the below to fix
this.
diff --git a/parse.c b/parse.c
index c8bae0335a4e..5c23d91ebab6 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;
--
Jens Axboe
^ permalink raw reply related [flat|nested] 3+ messages in thread
[parent not found: <20140219143639.168501090@linux.vnet.ibm.com>]
* [patch 3/9] fio: allow milliseconds on all time specifiers
[not found] <20140219143639.168501090@linux.vnet.ibm.com>
@ 2014-02-19 15:12 ` Christian Ehrhardt
0 siblings, 0 replies; 3+ messages in thread
From: Christian Ehrhardt @ 2014-02-19 15:12 UTC (permalink / raw)
To: fio; +Cc: oberpar, Christian Ehrhardt
From: Christian Ehrhardt <ehrhardt@linux.vnet.ibm.com>
This patch allows all time specifiers to be specified down to milliseconds.
Default will stay seconds for compatibility with old configs.
It also adds documentation to the existing time units day, hour and minute.
Signed-off-by: Christian Ehrhardt <ehrhardt@linux.vnet.ibm.com>
---
[diffstat]
backend.c | 4 ++--
eta.c | 14 ++++++++------
fio.1 | 16 ++++++++++------
parse.c | 48 ++++++++++++++++++++++++++++++++++--------------
time.c | 2 +-
5 files changed, 55 insertions(+), 29 deletions(-)
[diff]
--- a/backend.c
+++ b/backend.c
@@ -346,7 +346,7 @@ static inline int runtime_exceeded(struc
return 0;
if (!td->o.timeout)
return 0;
- if (mtime_since(&td->epoch, t) >= td->o.timeout * 1000)
+ if (mtime_since(&td->epoch, t) >= td->o.timeout )
return 1;
return 0;
@@ -1783,7 +1783,7 @@ static void run_threads(void)
if (td->o.start_delay) {
spent = mtime_since_genesis();
- if (td->o.start_delay * 1000 > spent)
+ if (td->o.start_delay > spent)
continue;
}
--- a/eta.c
+++ b/eta.c
@@ -174,7 +174,8 @@ static int thread_eta(struct thread_data
perc = 1.0;
if (td->o.time_based) {
- perc_t = (double) elapsed / (double) td->o.timeout;
+ perc_t = (double) elapsed /
+ (double) (td->o.timeout / 1000);
if (perc_t < perc)
perc = perc_t;
}
@@ -182,8 +183,9 @@ static int thread_eta(struct thread_data
eta_sec = (unsigned long) (elapsed * (1.0 / perc)) - elapsed;
if (td->o.timeout &&
- eta_sec > (td->o.timeout + done_secs - elapsed))
- eta_sec = td->o.timeout + done_secs - elapsed;
+ eta_sec > ( (td->o.timeout / 1000) + done_secs - elapsed))
+ eta_sec = (td->o.timeout / 1000) + done_secs
+ - elapsed;
} else if (td->runstate == TD_NOT_CREATED || td->runstate == TD_CREATED
|| td->runstate == TD_INITIALIZED
|| td->runstate == TD_SETTING_UP
@@ -197,8 +199,8 @@ static int thread_eta(struct thread_data
* if given, otherwise assume it'll run at the specified rate.
*/
if (td->o.timeout) {
- t_eta = td->o.timeout + td->o.start_delay +
- td->o.ramp_time;
+ t_eta = (td->o.timeout + td->o.start_delay +
+ td->o.ramp_time ) / 1000;
if (in_ramp_time(td)) {
unsigned long ramp_left;
@@ -212,7 +214,7 @@ static int thread_eta(struct thread_data
rate_bytes = ddir_rw_sum(td->o.rate);
if (rate_bytes) {
r_eta = (bytes_total / 1024) / rate_bytes;
- r_eta += td->o.start_delay;
+ r_eta += td->o.start_delay / 1000;
}
if (r_eta && t_eta)
--- a/fio.1
+++ b/fio.1
@@ -121,12 +121,16 @@ String: a sequence of alphanumeric chara
SI integer: a whole number, possibly containing a suffix denoting the
base unit
of the value. Accepted suffixes are `k', 'M', 'G', 'T', and 'P', denoting
kilo (1024), mega (1024^2), giga (1024^3), tera (1024^4), and peta
(1024^5)
-respectively. The suffix is not case sensitive. If prefixed with '0x', the
-value is assumed to be base 16 (hexadecimal). A suffix may include a
trailing 'b',
-for instance 'kb' is identical to 'k'. You can specify a base 10 value
-by using 'KiB', 'MiB', 'GiB', etc. This is useful for disk drives where
-values are often given in base 10 values. Specifying '30GiB' will get you
-30*1000^3 bytes.
+respectively. If prefixed with '0x', the value is assumed to be base 16
+(hexadecimal). A suffix may include a trailing 'b', for instance 'kb' is
+identical to 'k'. You can specify a base 10 value by using 'KiB',
'MiB','GiB',
+etc. This is useful for disk drives where values are often given in base 10
+values. Specifying '30GiB' will get you 30*1000^3 bytes.
+When specifying times the default suffix meaning changes, still
denoting the
+base unit of the value, but accepted suffixes are 'D' (days), 'H'
(hours), 'M'
+(minutes), 'S' Seconds, 'ms' milli seconds. Time values without a unit
specify
+seconds.
+The suffixes are not case sensitive.
.TP
.I bool
Boolean: a true or false value. `0' denotes false, `1' denotes true.
--- a/parse.c
+++ b/parse.c
@@ -122,21 +122,41 @@ static void show_option_help(struct fio_
show_option_values(o);
}
-static unsigned long get_mult_time(char c)
+static unsigned long long get_mult_time(const char *str, int len)
{
- switch (c) {
- case 'm':
- case 'M':
- return 60;
- case 'h':
- case 'H':
- return 60 * 60;
- case 'd':
- case 'D':
- return 24 * 60 * 60;
- default:
- return 1;
+ const char *p = str;
+ char *c;
+ unsigned long long mult = 1000;
+
+ /*
+ * Go forward until we hit a non-digit, or +/- sign
+ */
+ while ((p - str) <= len) {
+ if (!isdigit((int) *p) && (*p != '+') && (*p != '-'))
+ break;
+ p++;
}
+
+ if (!isalpha((int) *p))
+ return 1000;
+
+ c = strdup(p);
+ for (int i = 0; i < strlen(c); i++)
+ c[i] = tolower(c[i]);
+
+ if (!strncmp("ms", c, 2))
+ mult = 1;
+ else if (!strcmp("s", c))
+ mult = 1000;
+ else if (!strcmp("m", c))
+ mult = 60 * 1000;
+ else if (!strcmp("h", c))
+ mult = 60 * 60 * 1000;
+ else if (!strcmp("d", c))
+ mult = 24 * 60 * 60 * 1000;
+
+ free(c);
+ return mult;
}
static int is_separator(char c)
@@ -275,7 +295,7 @@ int str_to_decimal(const char *str, long
else
*val *= mult;
} else
- *val *= get_mult_time(str[len - 1]);
+ *val *= get_mult_time(str, len);
return 0;
}
--- a/time.c
+++ b/time.c
@@ -71,7 +71,7 @@ int ramp_time_over(struct thread_data *t
return 1;
fio_gettime(&tv, NULL);
- if (mtime_since(&td->epoch, &tv) >= td->o.ramp_time * 1000) {
+ if (mtime_since(&td->epoch, &tv) >= td->o.ramp_time ) {
td->ramp_time_over = 1;
reset_all_stats(td);
td_set_runstate(td, TD_RAMP);
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-02-21 19:49 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-02-20 13:20 [patch 3/9] fio: allow milliseconds on all time specifiers ehrhardt
2014-02-21 19:49 ` Jens Axboe
[not found] <20140219143639.168501090@linux.vnet.ibm.com>
2014-02-19 15:12 ` Christian Ehrhardt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox