Merge branch 'master' into gfio
[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
JA
16 "filename=.fio.tio.1:.fio.tio.2:.fio.tio.3:.fio.tio.4",
17 "name=seqwrite", "rw=write", "end_fsync=1",
18 "name=randwrite", "stonewall", "rw=randwrite", "end_fsync=1",
19 "name=seqread", "stonewall", "rw=read",
20 "name=randread", "stonewall", "rw=randread", NULL,
21};
22
e2de69da
JA
23static struct fio_option options[] = {
24 {
25 .name = "size",
2363d8df 26 .type = FIO_OPT_STR_VAL,
e2de69da
JA
27 .roff1 = &size,
28 .help = "Size in MB",
767a0a66 29 .category = FIO_OPT_G_IO,
e2de69da
JA
30 },
31 {
32 .name = "block",
33 .type = FIO_OPT_INT,
34 .roff1 = &bs,
35 .help = "Block size in bytes",
36 .def = "4k",
767a0a66 37 .category = FIO_OPT_G_IO,
e2de69da
JA
38 },
39 {
40 .name = "numruns",
41 .type = FIO_OPT_INT,
42 .roff1 = &loops,
43 .help = "Number of runs",
767a0a66 44 .category = FIO_OPT_G_JOB,
e2de69da
JA
45 },
46 {
47 .name = "dir",
48 .type = FIO_OPT_STR_STORE,
49 .roff1 = &dir,
50 .help = "Test directory",
767a0a66 51 .category = FIO_OPT_G_FILE,
e2de69da 52 },
2363d8df
JA
53 {
54 .name = "threads",
55 .type = FIO_OPT_INT,
56 .roff1 = &nthreads,
57 .help = "Number of Threads",
767a0a66 58 .category = FIO_OPT_G_JOB,
2363d8df 59 },
e2de69da
JA
60 {
61 .name = NULL,
62 },
63};
64
2363d8df
JA
65/*
66 * Fill our private options into the command line
67 */
68static void tb_prep_cmdline(void)
69{
70
71 /*
72 * tiobench uses size as MB, so multiply up
73 */
74 size *= 1024 * 1024ULL;
75 if (size)
76 sprintf(sz_idx, "size=%llu", size);
77 else
78 strcpy(sz_idx, "size=4*1024*$mb_memory");
79
80 sprintf(bs_idx, "bs=%u", bs);
81 sprintf(loop_idx, "loops=%u", loops);
82
83 if (dir)
84 sprintf(dir_idx, "directory=%s", dir);
85 else
86 sprintf(dir_idx, "directory=./");
87
88 sprintf(t_idx, "numjobs=%u", nthreads);
89}
90
79d16311
JA
91static struct profile_ops tiobench_profile = {
92 .name = "tiobench",
f5b6bb85 93 .desc = "tiotest/tiobench benchmark",
e2de69da 94 .options = options,
2363d8df
JA
95 .prep_cmd = tb_prep_cmdline,
96 .cmdline = tb_opts,
79d16311
JA
97};
98
99static void fio_init tiobench_register(void)
100{
07b3232d
JA
101 if (register_profile(&tiobench_profile))
102 log_err("fio: failed to register profile 'tiobench'\n");
79d16311
JA
103}
104
105static void fio_exit tiobench_unregister(void)
106{
107 unregister_profile(&tiobench_profile);
108}