Merge branch 'master' of ssh://git.kernel.dk/data/git/fio
[fio.git] / profiles / tiobench.c
... / ...
CommitLineData
1#include "../fio.h"
2#include "../profile.h"
3#include "../parse.h"
4
5static unsigned long long size;
6static unsigned int loops = 1;
7static unsigned int bs = 4096;
8static unsigned int nthreads = 1;
9static char *dir;
10
11char sz_idx[80], bs_idx[80], loop_idx[80], dir_idx[80], t_idx[80];
12
13static const char *tb_opts[] = {
14 "buffered=0", sz_idx, bs_idx, loop_idx, dir_idx, t_idx,
15 "timeout=600", "group_reporting", "thread", "overwrite=1",
16 "filename=.fio.tio.1:.fio.tio.2:.fio.tio.3:.fio.tio.4",
17 "ioengine=sync",
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
24static struct fio_option options[] = {
25 {
26 .name = "size",
27 .lname = "Tiobench size",
28 .type = FIO_OPT_STR_VAL,
29 .roff1 = &size,
30 .help = "Size in MB",
31 .category = FIO_OPT_C_PROFILE,
32 .group = FIO_OPT_G_TIOBENCH,
33 },
34 {
35 .name = "block",
36 .lname = "Tiobench block",
37 .type = FIO_OPT_INT,
38 .roff1 = &bs,
39 .help = "Block size in bytes",
40 .def = "4k",
41 .category = FIO_OPT_C_PROFILE,
42 .group = FIO_OPT_G_TIOBENCH,
43 },
44 {
45 .name = "numruns",
46 .lname = "Tiobench numruns",
47 .type = FIO_OPT_INT,
48 .roff1 = &loops,
49 .help = "Number of runs",
50 .category = FIO_OPT_C_PROFILE,
51 .group = FIO_OPT_G_TIOBENCH,
52 },
53 {
54 .name = "dir",
55 .lname = "Tiobench directory",
56 .type = FIO_OPT_STR_STORE,
57 .roff1 = &dir,
58 .help = "Test directory",
59 .category = FIO_OPT_C_PROFILE,
60 .group = FIO_OPT_G_TIOBENCH,
61 },
62 {
63 .name = "threads",
64 .lname = "Tiobench threads",
65 .type = FIO_OPT_INT,
66 .roff1 = &nthreads,
67 .help = "Number of Threads",
68 .category = FIO_OPT_C_PROFILE,
69 .group = FIO_OPT_G_TIOBENCH,
70 },
71 {
72 .name = NULL,
73 },
74};
75
76/*
77 * Fill our private options into the command line
78 */
79static int tb_prep_cmdline(void)
80{
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);
99 return 0;
100}
101
102static struct profile_ops tiobench_profile = {
103 .name = "tiobench",
104 .desc = "tiotest/tiobench benchmark",
105 .options = options,
106 .prep_cmd = tb_prep_cmdline,
107 .cmdline = tb_opts,
108};
109
110static void fio_init tiobench_register(void)
111{
112 if (register_profile(&tiobench_profile))
113 log_err("fio: failed to register profile 'tiobench'\n");
114}
115
116static void fio_exit tiobench_unregister(void)
117{
118 unregister_profile(&tiobench_profile);
119}