blob: bdb5985da006b11a4c611c48fc5e4e9e93f9b912 [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 Axboe2363d8d2010-03-04 14:30:02 +010011char sz_idx[80], bs_idx[80], loop_idx[80], dir_idx[80], t_idx[80];
12
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 Axboee2de69d2010-03-04 14:05:48 +010024static struct fio_option options[] = {
25 {
26 .name = "size",
Jens Axboee8b0e952012-03-19 14:37:08 +010027 .lname = "Tiobench size",
Jens Axboe2363d8d2010-03-04 14:30:02 +010028 .type = FIO_OPT_STR_VAL,
Jens Axboee2de69d2010-03-04 14:05:48 +010029 .roff1 = &size,
30 .help = "Size in MB",
Jens Axboe13fca822012-03-31 13:55:54 +020031 .category = FIO_OPT_C_PROFILE,
32 .group = FIO_OPT_G_TIOBENCH,
Jens Axboee2de69d2010-03-04 14:05:48 +010033 },
34 {
35 .name = "block",
Jens Axboee8b0e952012-03-19 14:37:08 +010036 .lname = "Tiobench block",
Jens Axboee2de69d2010-03-04 14:05:48 +010037 .type = FIO_OPT_INT,
38 .roff1 = &bs,
39 .help = "Block size in bytes",
40 .def = "4k",
Jens Axboe13fca822012-03-31 13:55:54 +020041 .category = FIO_OPT_C_PROFILE,
42 .group = FIO_OPT_G_TIOBENCH,
Jens Axboee2de69d2010-03-04 14:05:48 +010043 },
44 {
45 .name = "numruns",
Jens Axboee8b0e952012-03-19 14:37:08 +010046 .lname = "Tiobench numruns",
Jens Axboee2de69d2010-03-04 14:05:48 +010047 .type = FIO_OPT_INT,
48 .roff1 = &loops,
49 .help = "Number of runs",
Jens Axboe13fca822012-03-31 13:55:54 +020050 .category = FIO_OPT_C_PROFILE,
51 .group = FIO_OPT_G_TIOBENCH,
Jens Axboee2de69d2010-03-04 14:05:48 +010052 },
53 {
54 .name = "dir",
Jens Axboee8b0e952012-03-19 14:37:08 +010055 .lname = "Tiobench directory",
Jens Axboee2de69d2010-03-04 14:05:48 +010056 .type = FIO_OPT_STR_STORE,
57 .roff1 = &dir,
58 .help = "Test directory",
Jens Axboe13fca822012-03-31 13:55:54 +020059 .category = FIO_OPT_C_PROFILE,
60 .group = FIO_OPT_G_TIOBENCH,
Jens Axboee2de69d2010-03-04 14:05:48 +010061 },
62 {
Jens Axboe2363d8d2010-03-04 14:30:02 +010063 .name = "threads",
Jens Axboee8b0e952012-03-19 14:37:08 +010064 .lname = "Tiobench threads",
Jens Axboe2363d8d2010-03-04 14:30:02 +010065 .type = FIO_OPT_INT,
66 .roff1 = &nthreads,
67 .help = "Number of Threads",
Jens Axboe13fca822012-03-31 13:55:54 +020068 .category = FIO_OPT_C_PROFILE,
69 .group = FIO_OPT_G_TIOBENCH,
Jens Axboe2363d8d2010-03-04 14:30:02 +010070 },
71 {
Jens Axboee2de69d2010-03-04 14:05:48 +010072 .name = NULL,
73 },
74};
75
Jens Axboe2363d8d2010-03-04 14:30:02 +010076/*
77 * Fill our private options into the command line
78 */
Jens Axboed4afedf2013-05-22 22:21:29 +020079static int tb_prep_cmdline(void)
Jens Axboe2363d8d2010-03-04 14:30:02 +010080{
Jens Axboe2363d8d2010-03-04 14:30:02 +010081 /*
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);
Jens Axboed4afedf2013-05-22 22:21:29 +020099 return 0;
Jens Axboe2363d8d2010-03-04 14:30:02 +0100100}
101
Jens Axboe79d16312010-03-04 12:43:20 +0100102static struct profile_ops tiobench_profile = {
103 .name = "tiobench",
Jens Axboef5b6bb82010-03-05 10:09:59 +0100104 .desc = "tiotest/tiobench benchmark",
Jens Axboee2de69d2010-03-04 14:05:48 +0100105 .options = options,
Jens Axboe2363d8d2010-03-04 14:30:02 +0100106 .prep_cmd = tb_prep_cmdline,
107 .cmdline = tb_opts,
Jens Axboe79d16312010-03-04 12:43:20 +0100108};
109
110static void fio_init tiobench_register(void)
111{
Jens Axboe07b32322010-03-05 09:48:44 +0100112 if (register_profile(&tiobench_profile))
113 log_err("fio: failed to register profile 'tiobench'\n");
Jens Axboe79d16312010-03-04 12:43:20 +0100114}
115
116static void fio_exit tiobench_unregister(void)
117{
118 unregister_profile(&tiobench_profile);
119}