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