summaryrefslogtreecommitdiff
path: root/parse.c
diff options
context:
space:
mode:
authorRobert Elliott <elliott@hpe.com>2016-12-22 14:50:50 -0600
committerJens Axboe <axboe@fb.com>2017-01-02 18:19:49 -0700
commitd694a6a7c02f577b2bb5d0ad24331b775acf6869 (patch)
treefe148c1bb9da81c9216cec16a9a81045a3b987bc /parse.c
parent420b104a3f6ba4328b6b167808f71bb7849102ec (diff)
downloadfio-d694a6a7c02f577b2bb5d0ad24331b775acf6869.tar.gz
fio-d694a6a7c02f577b2bb5d0ad24331b775acf6869.tar.bz2
Improve IEC binary and SI decimal prefix handling
Use kb_base=1000 to follow international standards for unit prefixes. To specify power-of-10 decimal values defined in the International System of Units (SI): Ki means kilo (K) or 1000 Mi means mega (M) or 1000**2 Gi means giga (G) or 1000**3 Ti means tera (T) or 1000**4 Pi means peta (P) or 1000**5 To specify power-of-2 binary values defined in IEC 80000-13: k means kibi (Ki) or 1024 M means mebi (Mi) or 1024**2 G means gibi (Gi) or 1024**3 T means tebi (Ti) or 1024**4 P means pebi (Pi) or 1024**5 For example, this specifies a blocksize of 4096 bytes: kb_base=1000 bs=4KiB With kb_base=1024 (the default), the unit prefixes are opposite from those specified in the SI and IEC 80000-13 standards to provide compatibility with old scripts. For example, this specifies a blocksize of 4096 bytes: kb_base=1024 bs=4K For outputs printing quantities and bandwidths: * eta stats only use the preferred prefix * final stats include both (non-preferred prefix in parenthesis) * in gfio, all windows include both Text outputs are rearranged to try to obviously break any scripts parsing the output rather than silently confuse them. The terse and json outputs, which are intended for parsing, are unchanged. Old: Jobs: 576 (f=576), CR=86.4GB/576MB KB/s: [w(288),r(288)] [0.0% done] [33884MB/27114MB/0KB /s] [8471K/6778K/0 iops] [eta 06h:59m:57s] read: io=363338MB, bw=34014MB/s, iops=8304.3K, runt= 10682msec write: io=282447MB, bw=26225MB/s, iops=6402.7K, runt= 10770msec READ: io=363338MB, aggrb=34014MB/s, minb=34014MB/s, maxb=34014MB/s, mint=10682msec, maxt=10682msec WRITE: io=282447MB, aggrb=26225MB/s, minb=26225MB/s, maxb=26225MB/s, mint=10770msec, maxt=10770msec New: Jobs: 576 (f=576), 590MB/s-89.2GB/s: [w(288),r(288)][0.0%][r=34.2GB/s,w=26.3GB/s][r=8542k,w=6572k IOPS][eta 06h:59m:55s] read: IOPS=8362k, BW=34.3GB/s (31.1GiB/s)(665GB/19417msec) write: IOPS=6423k, BW=26.4GB/s (24.6GiB/s)(511GB/19431msec) READ: bw=34.3GB/s (31.1GiB/s), 34.3GB/s-34.3GB/s (31.1GiB/s-31.1GiB/s), io=665GB (619GiB), run=19417-19417msec WRITE: bw=26.4GB/s (24.6GiB/s), 26.4GB/s-26.4GB/s (24.6GiB/s-24.6GiB/s), io=511GB (476GiB), run=19431-19431msec Documentation changes are in a subsequent patch. Signed-off-by: Jens Axboe <axboe@fb.com>
Diffstat (limited to 'parse.c')
-rw-r--r--parse.c40
1 files changed, 29 insertions, 11 deletions
diff --git a/parse.c b/parse.c
index 8ed4619e..518c2dff 100644
--- a/parse.c
+++ b/parse.c
@@ -207,32 +207,50 @@ static unsigned long long __get_mult_bytes(const char *p, void *data,
}
}
+ /* If kb_base is 1000, use true units.
+ * If kb_base is 1024, use opposite units.
+ */
if (!strncmp("pib", c, 3)) {
pow = 5;
- mult = 1000;
+ if (kb_base == 1000)
+ mult = 1024;
+ else if (kb_base == 1024)
+ mult = 1000;
} else if (!strncmp("tib", c, 3)) {
pow = 4;
- mult = 1000;
+ if (kb_base == 1000)
+ mult = 1024;
+ else if (kb_base == 1024)
+ mult = 1000;
} else if (!strncmp("gib", c, 3)) {
pow = 3;
- mult = 1000;
+ if (kb_base == 1000)
+ mult = 1024;
+ else if (kb_base == 1024)
+ mult = 1000;
} else if (!strncmp("mib", c, 3)) {
pow = 2;
- mult = 1000;
+ if (kb_base == 1000)
+ mult = 1024;
+ else if (kb_base == 1024)
+ mult = 1000;
} else if (!strncmp("kib", c, 3)) {
pow = 1;
- mult = 1000;
- } else if (!strncmp("p", c, 1) || !strncmp("pb", c, 2))
+ if (kb_base == 1000)
+ mult = 1024;
+ else if (kb_base == 1024)
+ mult = 1000;
+ } else if (!strncmp("p", c, 1) || !strncmp("pb", c, 2)) {
pow = 5;
- else if (!strncmp("t", c, 1) || !strncmp("tb", c, 2))
+ } else if (!strncmp("t", c, 1) || !strncmp("tb", c, 2)) {
pow = 4;
- else if (!strncmp("g", c, 1) || !strncmp("gb", c, 2))
+ } else if (!strncmp("g", c, 1) || !strncmp("gb", c, 2)) {
pow = 3;
- else if (!strncmp("m", c, 1) || !strncmp("mb", c, 2))
+ } else if (!strncmp("m", c, 1) || !strncmp("mb", c, 2)) {
pow = 2;
- else if (!strncmp("k", c, 1) || !strncmp("kb", c, 2))
+ } else if (!strncmp("k", c, 1) || !strncmp("kb", c, 2)) {
pow = 1;
- else if (!strncmp("%", c, 1)) {
+ } else if (!strncmp("%", c, 1)) {
*percent = 1;
free(c);
return ret;