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