parse: enable options to be marked dont-free
[fio.git] / profiles / tiobench.c
... / ...
CommitLineData
1#include "../fio.h"
2#include "../profile.h"
3#include "../parse.h"
4#include "../optgroup.h"
5
6static unsigned long long size;
7static unsigned int loops = 1;
8static unsigned int bs = 4096;
9static unsigned int nthreads = 1;
10static char *dir;
11
12static char sz_idx[80], bs_idx[80], loop_idx[80], dir_idx[80], t_idx[80];
13
14static const char *tb_opts[] = {
15 "buffered=0", sz_idx, bs_idx, loop_idx, dir_idx, t_idx,
16 "timeout=600", "group_reporting", "thread", "overwrite=1",
17 "filename=.fio.tio.1:.fio.tio.2:.fio.tio.3:.fio.tio.4",
18 "ioengine=sync",
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
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
36static struct fio_option options[] = {
37 {
38 .name = "size",
39 .lname = "Tiobench size",
40 .type = FIO_OPT_STR_VAL,
41 .off1 = offsetof(struct tiobench_options, size),
42 .help = "Size in MiB",
43 .category = FIO_OPT_C_PROFILE,
44 .group = FIO_OPT_G_TIOBENCH,
45 },
46 {
47 .name = "block",
48 .lname = "Tiobench block",
49 .type = FIO_OPT_INT,
50 .off1 = offsetof(struct tiobench_options, bs),
51 .help = "Block size in bytes",
52 .def = "4096",
53 .category = FIO_OPT_C_PROFILE,
54 .group = FIO_OPT_G_TIOBENCH,
55 },
56 {
57 .name = "numruns",
58 .lname = "Tiobench numruns",
59 .type = FIO_OPT_INT,
60 .off1 = offsetof(struct tiobench_options, loops),
61 .help = "Number of runs",
62 .category = FIO_OPT_C_PROFILE,
63 .group = FIO_OPT_G_TIOBENCH,
64 },
65 {
66 .name = "dir",
67 .lname = "Tiobench directory",
68 .type = FIO_OPT_STR_STORE,
69 .off1 = offsetof(struct tiobench_options, dir),
70 .help = "Test directory",
71 .category = FIO_OPT_C_PROFILE,
72 .group = FIO_OPT_G_TIOBENCH,
73 .no_free = true,
74 },
75 {
76 .name = "threads",
77 .lname = "Tiobench threads",
78 .type = FIO_OPT_INT,
79 .off1 = offsetof(struct tiobench_options, nthreads),
80 .help = "Number of Threads",
81 .category = FIO_OPT_C_PROFILE,
82 .group = FIO_OPT_G_TIOBENCH,
83 },
84 {
85 .name = NULL,
86 },
87};
88
89/*
90 * Fill our private options into the command line
91 */
92static int tb_prep_cmdline(void)
93{
94 /*
95 * tiobench uses size as MiB, so multiply up
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);
112 return 0;
113}
114
115static struct profile_ops tiobench_profile = {
116 .name = "tiobench",
117 .desc = "tiotest/tiobench benchmark",
118 .prep_cmd = tb_prep_cmdline,
119 .cmdline = tb_opts,
120 .options = options,
121 .opt_data = &tiobench_options,
122};
123
124static void fio_init tiobench_register(void)
125{
126 if (register_profile(&tiobench_profile))
127 log_err("fio: failed to register profile 'tiobench'\n");
128}
129
130static void fio_exit tiobench_unregister(void)
131{
132 unregister_profile(&tiobench_profile);
133}