blob: b4331d75ae52c00437c9183d1ef4e76dc7cdf7ca [file] [log] [blame]
Jens Axboe79d16312010-03-04 12:43:20 +01001#include "../fio.h"
2#include "../profile.h"
Jens Axboee2de69d2010-03-04 14:05:48 +01003#include "../parse.h"
4
Jens Axboe2363d8d2010-03-04 14:30:02 +01005static unsigned long long size;
6static unsigned int loops = 1;
7static unsigned int bs = 4096;
8static unsigned int nthreads = 1;
Jens Axboee2de69d2010-03-04 14:05:48 +01009static char *dir;
Jens Axboe79d16312010-03-04 12:43:20 +010010
Jens Axboe10aa1362014-04-01 21:10:36 -060011static char sz_idx[80], bs_idx[80], loop_idx[80], dir_idx[80], t_idx[80];
Jens Axboe2363d8d2010-03-04 14:30:02 +010012
Jens Axboe79d16312010-03-04 12:43:20 +010013static const char *tb_opts[] = {
Jens Axboe2363d8d2010-03-04 14:30:02 +010014 "buffered=0", sz_idx, bs_idx, loop_idx, dir_idx, t_idx,
15 "timeout=600", "group_reporting", "thread", "overwrite=1",
Jens Axboe79d16312010-03-04 12:43:20 +010016 "filename=.fio.tio.1:.fio.tio.2:.fio.tio.3:.fio.tio.4",
Jens Axboe774a99b2013-05-23 21:31:35 +020017 "ioengine=sync",
Jens Axboe79d16312010-03-04 12:43:20 +010018 "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
Jens Axboe7b504ed2014-02-11 14:19:38 -070024struct 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
Jens Axboee2de69d2010-03-04 14:05:48 +010035static struct fio_option options[] = {
36 {
37 .name = "size",
Jens Axboee8b0e952012-03-19 14:37:08 +010038 .lname = "Tiobench size",
Jens Axboe2363d8d2010-03-04 14:30:02 +010039 .type = FIO_OPT_STR_VAL,
Jens Axboe7b504ed2014-02-11 14:19:38 -070040 .off1 = offsetof(struct tiobench_options, size),
Jens Axboee2de69d2010-03-04 14:05:48 +010041 .help = "Size in MB",
Jens Axboe13fca822012-03-31 13:55:54 +020042 .category = FIO_OPT_C_PROFILE,
43 .group = FIO_OPT_G_TIOBENCH,
Jens Axboee2de69d2010-03-04 14:05:48 +010044 },
45 {
46 .name = "block",
Jens Axboee8b0e952012-03-19 14:37:08 +010047 .lname = "Tiobench block",
Jens Axboee2de69d2010-03-04 14:05:48 +010048 .type = FIO_OPT_INT,
Jens Axboe7b504ed2014-02-11 14:19:38 -070049 .off1 = offsetof(struct tiobench_options, bs),
Jens Axboee2de69d2010-03-04 14:05:48 +010050 .help = "Block size in bytes",
51 .def = "4k",
Jens Axboe13fca822012-03-31 13:55:54 +020052 .category = FIO_OPT_C_PROFILE,
53 .group = FIO_OPT_G_TIOBENCH,
Jens Axboee2de69d2010-03-04 14:05:48 +010054 },
55 {
56 .name = "numruns",
Jens Axboee8b0e952012-03-19 14:37:08 +010057 .lname = "Tiobench numruns",
Jens Axboee2de69d2010-03-04 14:05:48 +010058 .type = FIO_OPT_INT,
Jens Axboe7b504ed2014-02-11 14:19:38 -070059 .off1 = offsetof(struct tiobench_options, loops),
Jens Axboee2de69d2010-03-04 14:05:48 +010060 .help = "Number of runs",
Jens Axboe13fca822012-03-31 13:55:54 +020061 .category = FIO_OPT_C_PROFILE,
62 .group = FIO_OPT_G_TIOBENCH,
Jens Axboee2de69d2010-03-04 14:05:48 +010063 },
64 {
65 .name = "dir",
Jens Axboee8b0e952012-03-19 14:37:08 +010066 .lname = "Tiobench directory",
Jens Axboee2de69d2010-03-04 14:05:48 +010067 .type = FIO_OPT_STR_STORE,
Jens Axboe7b504ed2014-02-11 14:19:38 -070068 .off1 = offsetof(struct tiobench_options, dir),
Jens Axboee2de69d2010-03-04 14:05:48 +010069 .help = "Test directory",
Jens Axboe13fca822012-03-31 13:55:54 +020070 .category = FIO_OPT_C_PROFILE,
71 .group = FIO_OPT_G_TIOBENCH,
Jens Axboee2de69d2010-03-04 14:05:48 +010072 },
73 {
Jens Axboe2363d8d2010-03-04 14:30:02 +010074 .name = "threads",
Jens Axboee8b0e952012-03-19 14:37:08 +010075 .lname = "Tiobench threads",
Jens Axboe2363d8d2010-03-04 14:30:02 +010076 .type = FIO_OPT_INT,
Jens Axboe7b504ed2014-02-11 14:19:38 -070077 .off1 = offsetof(struct tiobench_options, nthreads),
Jens Axboe2363d8d2010-03-04 14:30:02 +010078 .help = "Number of Threads",
Jens Axboe13fca822012-03-31 13:55:54 +020079 .category = FIO_OPT_C_PROFILE,
80 .group = FIO_OPT_G_TIOBENCH,
Jens Axboe2363d8d2010-03-04 14:30:02 +010081 },
82 {
Jens Axboee2de69d2010-03-04 14:05:48 +010083 .name = NULL,
84 },
85};
86
Jens Axboe2363d8d2010-03-04 14:30:02 +010087/*
88 * Fill our private options into the command line
89 */
Jens Axboed4afedf2013-05-22 22:21:29 +020090static int tb_prep_cmdline(void)
Jens Axboe2363d8d2010-03-04 14:30:02 +010091{
Jens Axboe2363d8d2010-03-04 14:30:02 +010092 /*
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);
Jens Axboed4afedf2013-05-22 22:21:29 +0200110 return 0;
Jens Axboe2363d8d2010-03-04 14:30:02 +0100111}
112
Jens Axboe79d16312010-03-04 12:43:20 +0100113static struct profile_ops tiobench_profile = {
114 .name = "tiobench",
Jens Axboef5b6bb82010-03-05 10:09:59 +0100115 .desc = "tiotest/tiobench benchmark",
Jens Axboe2363d8d2010-03-04 14:30:02 +0100116 .prep_cmd = tb_prep_cmdline,
117 .cmdline = tb_opts,
Jens Axboe7b504ed2014-02-11 14:19:38 -0700118 .options = options,
119 .opt_data = &tiobench_options,
Jens Axboe79d16312010-03-04 12:43:20 +0100120};
121
122static void fio_init tiobench_register(void)
123{
Jens Axboe07b32322010-03-05 09:48:44 +0100124 if (register_profile(&tiobench_profile))
125 log_err("fio: failed to register profile 'tiobench'\n");
Jens Axboe79d16312010-03-04 12:43:20 +0100126}
127
128static void fio_exit tiobench_unregister(void)
129{
130 unregister_profile(&tiobench_profile);
131}