parse: get rid of raw option offsets
[fio.git] / profiles / tiobench.c
CommitLineData
79d16311
JA
1#include "../fio.h"
2#include "../profile.h"
e2de69da
JA
3#include "../parse.h"
4
2363d8df
JA
5static unsigned long long size;
6static unsigned int loops = 1;
7static unsigned int bs = 4096;
8static unsigned int nthreads = 1;
e2de69da 9static char *dir;
79d16311 10
2363d8df
JA
11char sz_idx[80], bs_idx[80], loop_idx[80], dir_idx[80], t_idx[80];
12
79d16311 13static const char *tb_opts[] = {
2363d8df
JA
14 "buffered=0", sz_idx, bs_idx, loop_idx, dir_idx, t_idx,
15 "timeout=600", "group_reporting", "thread", "overwrite=1",
79d16311 16 "filename=.fio.tio.1:.fio.tio.2:.fio.tio.3:.fio.tio.4",
774a99b5 17 "ioengine=sync",
79d16311
JA
18 "name=seqwrite", "rw=write", "end_fsync=1",
19 "name=randwrite", "stonewall", "rw=randwrite", "end_fsync=1",
20 "name=seqread", "stonewall", "rw=read",
21 "name=randread", "stonewall", "rw=randread", NULL,
22};
23
7b504edd
JA
24struct tiobench_options {
25 unsigned int pad;
26 unsigned long long size;
27 unsigned int loops;
28 unsigned int bs;
29 unsigned int nthreads;
30 char *dir;
31};
32
33static struct tiobench_options tiobench_options;
34
e2de69da
JA
35static struct fio_option options[] = {
36 {
37 .name = "size",
e8b0e958 38 .lname = "Tiobench size",
2363d8df 39 .type = FIO_OPT_STR_VAL,
7b504edd 40 .off1 = offsetof(struct tiobench_options, size),
e2de69da 41 .help = "Size in MB",
13fca827
JA
42 .category = FIO_OPT_C_PROFILE,
43 .group = FIO_OPT_G_TIOBENCH,
e2de69da
JA
44 },
45 {
46 .name = "block",
e8b0e958 47 .lname = "Tiobench block",
e2de69da 48 .type = FIO_OPT_INT,
7b504edd 49 .off1 = offsetof(struct tiobench_options, bs),
e2de69da
JA
50 .help = "Block size in bytes",
51 .def = "4k",
13fca827
JA
52 .category = FIO_OPT_C_PROFILE,
53 .group = FIO_OPT_G_TIOBENCH,
e2de69da
JA
54 },
55 {
56 .name = "numruns",
e8b0e958 57 .lname = "Tiobench numruns",
e2de69da 58 .type = FIO_OPT_INT,
7b504edd 59 .off1 = offsetof(struct tiobench_options, loops),
e2de69da 60 .help = "Number of runs",
13fca827
JA
61 .category = FIO_OPT_C_PROFILE,
62 .group = FIO_OPT_G_TIOBENCH,
e2de69da
JA
63 },
64 {
65 .name = "dir",
e8b0e958 66 .lname = "Tiobench directory",
e2de69da 67 .type = FIO_OPT_STR_STORE,
7b504edd 68 .off1 = offsetof(struct tiobench_options, dir),
e2de69da 69 .help = "Test directory",
13fca827
JA
70 .category = FIO_OPT_C_PROFILE,
71 .group = FIO_OPT_G_TIOBENCH,
e2de69da 72 },
2363d8df
JA
73 {
74 .name = "threads",
e8b0e958 75 .lname = "Tiobench threads",
2363d8df 76 .type = FIO_OPT_INT,
7b504edd 77 .off1 = offsetof(struct tiobench_options, nthreads),
2363d8df 78 .help = "Number of Threads",
13fca827
JA
79 .category = FIO_OPT_C_PROFILE,
80 .group = FIO_OPT_G_TIOBENCH,
2363d8df 81 },
e2de69da
JA
82 {
83 .name = NULL,
84 },
85};
86
2363d8df
JA
87/*
88 * Fill our private options into the command line
89 */
d4afedfd 90static int tb_prep_cmdline(void)
2363d8df 91{
2363d8df
JA
92 /*
93 * tiobench uses size as MB, so multiply up
94 */
95 size *= 1024 * 1024ULL;
96 if (size)
97 sprintf(sz_idx, "size=%llu", size);
98 else
99 strcpy(sz_idx, "size=4*1024*$mb_memory");
100
101 sprintf(bs_idx, "bs=%u", bs);
102 sprintf(loop_idx, "loops=%u", loops);
103
104 if (dir)
105 sprintf(dir_idx, "directory=%s", dir);
106 else
107 sprintf(dir_idx, "directory=./");
108
109 sprintf(t_idx, "numjobs=%u", nthreads);
d4afedfd 110 return 0;
2363d8df
JA
111}
112
79d16311
JA
113static struct profile_ops tiobench_profile = {
114 .name = "tiobench",
f5b6bb85 115 .desc = "tiotest/tiobench benchmark",
e2de69da 116 .options = options,
2363d8df
JA
117 .prep_cmd = tb_prep_cmdline,
118 .cmdline = tb_opts,
7b504edd
JA
119 .options = options,
120 .opt_data = &tiobench_options,
79d16311
JA
121};
122
123static void fio_init tiobench_register(void)
124{
07b3232d
JA
125 if (register_profile(&tiobench_profile))
126 log_err("fio: failed to register profile 'tiobench'\n");
79d16311
JA
127}
128
129static void fio_exit tiobench_unregister(void)
130{
131 unregister_profile(&tiobench_profile);
132}