parse: enable options to be marked dont-free
[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),
4870138d 42 .help = "Size in MiB",
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 51 .help = "Block size in bytes",
2b9136a3 52 .def = "4096",
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,
43f466e6 73 .no_free = true,
e2de69da 74 },
2363d8df
JA
75 {
76 .name = "threads",
e8b0e958 77 .lname = "Tiobench threads",
2363d8df 78 .type = FIO_OPT_INT,
7b504edd 79 .off1 = offsetof(struct tiobench_options, nthreads),
2363d8df 80 .help = "Number of Threads",
13fca827
JA
81 .category = FIO_OPT_C_PROFILE,
82 .group = FIO_OPT_G_TIOBENCH,
2363d8df 83 },
e2de69da
JA
84 {
85 .name = NULL,
86 },
87};
88
2363d8df
JA
89/*
90 * Fill our private options into the command line
91 */
d4afedfd 92static int tb_prep_cmdline(void)
2363d8df 93{
2363d8df 94 /*
4870138d 95 * tiobench uses size as MiB, so multiply up
2363d8df
JA
96 */
97 size *= 1024 * 1024ULL;
98 if (size)
99 sprintf(sz_idx, "size=%llu", size);
100 else
101 strcpy(sz_idx, "size=4*1024*$mb_memory");
102
103 sprintf(bs_idx, "bs=%u", bs);
104 sprintf(loop_idx, "loops=%u", loops);
105
106 if (dir)
107 sprintf(dir_idx, "directory=%s", dir);
108 else
109 sprintf(dir_idx, "directory=./");
110
111 sprintf(t_idx, "numjobs=%u", nthreads);
d4afedfd 112 return 0;
2363d8df
JA
113}
114
79d16311
JA
115static struct profile_ops tiobench_profile = {
116 .name = "tiobench",
f5b6bb85 117 .desc = "tiotest/tiobench benchmark",
2363d8df
JA
118 .prep_cmd = tb_prep_cmdline,
119 .cmdline = tb_opts,
7b504edd
JA
120 .options = options,
121 .opt_data = &tiobench_options,
79d16311
JA
122};
123
124static void fio_init tiobench_register(void)
125{
07b3232d
JA
126 if (register_profile(&tiobench_profile))
127 log_err("fio: failed to register profile 'tiobench'\n");
79d16311
JA
128}
129
130static void fio_exit tiobench_unregister(void)
131{
132 unregister_profile(&tiobench_profile);
133}