summaryrefslogtreecommitdiff
path: root/profiles/tiobench.c
blob: f19a08577bb2450f0597cc9202e8c00c9eb495a6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#include "../fio.h"
#include "../profile.h"
#include "../parse.h"
#include "../optgroup.h"

static unsigned long long size;
static unsigned int loops = 1;
static unsigned int bs = 4096;
static unsigned int nthreads = 1;
static char *dir;

static char sz_idx[80], bs_idx[80], loop_idx[80], dir_idx[80], t_idx[80];

static const char *tb_opts[] = {
	"buffered=0", sz_idx, bs_idx, loop_idx, dir_idx, t_idx,
	"timeout=600", "group_reporting", "thread", "overwrite=1",
	"filename=.fio.tio.1:.fio.tio.2:.fio.tio.3:.fio.tio.4",
	"ioengine=sync",
	"name=seqwrite", "rw=write", "end_fsync=1",
	"name=randwrite", "stonewall", "rw=randwrite", "end_fsync=1",
	"name=seqread", "stonewall", "rw=read",
	"name=randread", "stonewall", "rw=randread", NULL,
};

struct tiobench_options {
	unsigned int pad;
	unsigned long long size;
	unsigned int loops;
	unsigned int bs;
	unsigned int nthreads;
	char *dir;
};

static struct tiobench_options tiobench_options;

static struct fio_option options[] = {
	{
		.name	= "size",
		.lname	= "Tiobench size",
		.type	= FIO_OPT_STR_VAL,
		.off1	= offsetof(struct tiobench_options, size),
		.help	= "Size in MiB",
		.category = FIO_OPT_C_PROFILE,
		.group	= FIO_OPT_G_TIOBENCH,
	},
	{
		.name	= "block",
		.lname	= "Tiobench block",
		.type	= FIO_OPT_INT,
		.off1	= offsetof(struct tiobench_options, bs),
		.help	= "Block size in bytes",
		.def	= "4096",
		.category = FIO_OPT_C_PROFILE,
		.group	= FIO_OPT_G_TIOBENCH,
	},
	{
		.name	= "numruns",
		.lname	= "Tiobench numruns",
		.type	= FIO_OPT_INT,
		.off1	= offsetof(struct tiobench_options, loops),
		.help	= "Number of runs",
		.category = FIO_OPT_C_PROFILE,
		.group	= FIO_OPT_G_TIOBENCH,
	},
	{
		.name	= "dir",
		.lname	= "Tiobench directory",
		.type	= FIO_OPT_STR_STORE,
		.off1	= offsetof(struct tiobench_options, dir),
		.help	= "Test directory",
		.category = FIO_OPT_C_PROFILE,
		.group	= FIO_OPT_G_TIOBENCH,
		.no_free = true,
	},
	{
		.name	= "threads",
		.lname	= "Tiobench threads",
		.type	= FIO_OPT_INT,
		.off1	= offsetof(struct tiobench_options, nthreads),
		.help	= "Number of Threads",
		.category = FIO_OPT_C_PROFILE,
		.group	= FIO_OPT_G_TIOBENCH,
	},
	{
		.name	= NULL,
	},
};

/*
 * Fill our private options into the command line
 */
static int tb_prep_cmdline(void)
{
	/*
	 * tiobench uses size as MiB, so multiply up
	 */
	size *= 1024 * 1024ULL;
	if (size)
		sprintf(sz_idx, "size=%llu", size);
	else
		strcpy(sz_idx, "size=4*1024*$mb_memory");

	sprintf(bs_idx, "bs=%u", bs);
	sprintf(loop_idx, "loops=%u", loops);

	if (dir)
		sprintf(dir_idx, "directory=%s", dir);
	else
		sprintf(dir_idx, "directory=./");

	sprintf(t_idx, "numjobs=%u", nthreads);
	return 0;
}

static struct profile_ops tiobench_profile = {
	.name		= "tiobench",
	.desc		= "tiotest/tiobench benchmark",
	.prep_cmd	= tb_prep_cmdline,
	.cmdline	= tb_opts,
	.options	= options,
	.opt_data	= &tiobench_options,
};

static void fio_init tiobench_register(void)
{
	if (register_profile(&tiobench_profile))
		log_err("fio: failed to register profile 'tiobench'\n");
}

static void fio_exit tiobench_unregister(void)
{
	unregister_profile(&tiobench_profile);
}