Merge branch 'master' of ssh://git.kernel.dk/data/git/fio
[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
e2de69da
JA
24static struct fio_option options[] = {
25 {
26 .name = "size",
e8b0e958 27 .lname = "Tiobench size",
2363d8df 28 .type = FIO_OPT_STR_VAL,
e2de69da
JA
29 .roff1 = &size,
30 .help = "Size in MB",
13fca827
JA
31 .category = FIO_OPT_C_PROFILE,
32 .group = FIO_OPT_G_TIOBENCH,
e2de69da
JA
33 },
34 {
35 .name = "block",
e8b0e958 36 .lname = "Tiobench block",
e2de69da
JA
37 .type = FIO_OPT_INT,
38 .roff1 = &bs,
39 .help = "Block size in bytes",
40 .def = "4k",
13fca827
JA
41 .category = FIO_OPT_C_PROFILE,
42 .group = FIO_OPT_G_TIOBENCH,
e2de69da
JA
43 },
44 {
45 .name = "numruns",
e8b0e958 46 .lname = "Tiobench numruns",
e2de69da
JA
47 .type = FIO_OPT_INT,
48 .roff1 = &loops,
49 .help = "Number of runs",
13fca827
JA
50 .category = FIO_OPT_C_PROFILE,
51 .group = FIO_OPT_G_TIOBENCH,
e2de69da
JA
52 },
53 {
54 .name = "dir",
e8b0e958 55 .lname = "Tiobench directory",
e2de69da
JA
56 .type = FIO_OPT_STR_STORE,
57 .roff1 = &dir,
58 .help = "Test directory",
13fca827
JA
59 .category = FIO_OPT_C_PROFILE,
60 .group = FIO_OPT_G_TIOBENCH,
e2de69da 61 },
2363d8df
JA
62 {
63 .name = "threads",
e8b0e958 64 .lname = "Tiobench threads",
2363d8df
JA
65 .type = FIO_OPT_INT,
66 .roff1 = &nthreads,
67 .help = "Number of Threads",
13fca827
JA
68 .category = FIO_OPT_C_PROFILE,
69 .group = FIO_OPT_G_TIOBENCH,
2363d8df 70 },
e2de69da
JA
71 {
72 .name = NULL,
73 },
74};
75
2363d8df
JA
76/*
77 * Fill our private options into the command line
78 */
d4afedfd 79static int tb_prep_cmdline(void)
2363d8df 80{
2363d8df
JA
81 /*
82 * tiobench uses size as MB, so multiply up
83 */
84 size *= 1024 * 1024ULL;
85 if (size)
86 sprintf(sz_idx, "size=%llu", size);
87 else
88 strcpy(sz_idx, "size=4*1024*$mb_memory");
89
90 sprintf(bs_idx, "bs=%u", bs);
91 sprintf(loop_idx, "loops=%u", loops);
92
93 if (dir)
94 sprintf(dir_idx, "directory=%s", dir);
95 else
96 sprintf(dir_idx, "directory=./");
97
98 sprintf(t_idx, "numjobs=%u", nthreads);
d4afedfd 99 return 0;
2363d8df
JA
100}
101
79d16311
JA
102static struct profile_ops tiobench_profile = {
103 .name = "tiobench",
f5b6bb85 104 .desc = "tiotest/tiobench benchmark",
e2de69da 105 .options = options,
2363d8df
JA
106 .prep_cmd = tb_prep_cmdline,
107 .cmdline = tb_opts,
79d16311
JA
108};
109
110static void fio_init tiobench_register(void)
111{
07b3232d
JA
112 if (register_profile(&tiobench_profile))
113 log_err("fio: failed to register profile 'tiobench'\n");
79d16311
JA
114}
115
116static void fio_exit tiobench_unregister(void)
117{
118 unregister_profile(&tiobench_profile);
119}