Jens Axboe | 79d1631 | 2010-03-04 12:43:20 +0100 | [diff] [blame] | 1 | #include "../fio.h" |
| 2 | #include "../profile.h" |
Jens Axboe | e2de69d | 2010-03-04 14:05:48 +0100 | [diff] [blame] | 3 | #include "../parse.h" |
| 4 | |
Jens Axboe | 2363d8d | 2010-03-04 14:30:02 +0100 | [diff] [blame] | 5 | static unsigned long long size; |
| 6 | static unsigned int loops = 1; |
| 7 | static unsigned int bs = 4096; |
| 8 | static unsigned int nthreads = 1; |
Jens Axboe | e2de69d | 2010-03-04 14:05:48 +0100 | [diff] [blame] | 9 | static char *dir; |
Jens Axboe | 79d1631 | 2010-03-04 12:43:20 +0100 | [diff] [blame] | 10 | |
Jens Axboe | 2363d8d | 2010-03-04 14:30:02 +0100 | [diff] [blame] | 11 | char sz_idx[80], bs_idx[80], loop_idx[80], dir_idx[80], t_idx[80]; |
| 12 | |
Jens Axboe | 79d1631 | 2010-03-04 12:43:20 +0100 | [diff] [blame] | 13 | static const char *tb_opts[] = { |
Jens Axboe | 2363d8d | 2010-03-04 14:30:02 +0100 | [diff] [blame] | 14 | "buffered=0", sz_idx, bs_idx, loop_idx, dir_idx, t_idx, |
| 15 | "timeout=600", "group_reporting", "thread", "overwrite=1", |
Jens Axboe | 79d1631 | 2010-03-04 12:43:20 +0100 | [diff] [blame] | 16 | "filename=.fio.tio.1:.fio.tio.2:.fio.tio.3:.fio.tio.4", |
Jens Axboe | 774a99b | 2013-05-23 21:31:35 +0200 | [diff] [blame] | 17 | "ioengine=sync", |
Jens Axboe | 79d1631 | 2010-03-04 12:43:20 +0100 | [diff] [blame] | 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 | |
Jens Axboe | e2de69d | 2010-03-04 14:05:48 +0100 | [diff] [blame] | 24 | static struct fio_option options[] = { |
| 25 | { |
| 26 | .name = "size", |
Jens Axboe | e8b0e95 | 2012-03-19 14:37:08 +0100 | [diff] [blame] | 27 | .lname = "Tiobench size", |
Jens Axboe | 2363d8d | 2010-03-04 14:30:02 +0100 | [diff] [blame] | 28 | .type = FIO_OPT_STR_VAL, |
Jens Axboe | e2de69d | 2010-03-04 14:05:48 +0100 | [diff] [blame] | 29 | .roff1 = &size, |
| 30 | .help = "Size in MB", |
Jens Axboe | 13fca82 | 2012-03-31 13:55:54 +0200 | [diff] [blame] | 31 | .category = FIO_OPT_C_PROFILE, |
| 32 | .group = FIO_OPT_G_TIOBENCH, |
Jens Axboe | e2de69d | 2010-03-04 14:05:48 +0100 | [diff] [blame] | 33 | }, |
| 34 | { |
| 35 | .name = "block", |
Jens Axboe | e8b0e95 | 2012-03-19 14:37:08 +0100 | [diff] [blame] | 36 | .lname = "Tiobench block", |
Jens Axboe | e2de69d | 2010-03-04 14:05:48 +0100 | [diff] [blame] | 37 | .type = FIO_OPT_INT, |
| 38 | .roff1 = &bs, |
| 39 | .help = "Block size in bytes", |
| 40 | .def = "4k", |
Jens Axboe | 13fca82 | 2012-03-31 13:55:54 +0200 | [diff] [blame] | 41 | .category = FIO_OPT_C_PROFILE, |
| 42 | .group = FIO_OPT_G_TIOBENCH, |
Jens Axboe | e2de69d | 2010-03-04 14:05:48 +0100 | [diff] [blame] | 43 | }, |
| 44 | { |
| 45 | .name = "numruns", |
Jens Axboe | e8b0e95 | 2012-03-19 14:37:08 +0100 | [diff] [blame] | 46 | .lname = "Tiobench numruns", |
Jens Axboe | e2de69d | 2010-03-04 14:05:48 +0100 | [diff] [blame] | 47 | .type = FIO_OPT_INT, |
| 48 | .roff1 = &loops, |
| 49 | .help = "Number of runs", |
Jens Axboe | 13fca82 | 2012-03-31 13:55:54 +0200 | [diff] [blame] | 50 | .category = FIO_OPT_C_PROFILE, |
| 51 | .group = FIO_OPT_G_TIOBENCH, |
Jens Axboe | e2de69d | 2010-03-04 14:05:48 +0100 | [diff] [blame] | 52 | }, |
| 53 | { |
| 54 | .name = "dir", |
Jens Axboe | e8b0e95 | 2012-03-19 14:37:08 +0100 | [diff] [blame] | 55 | .lname = "Tiobench directory", |
Jens Axboe | e2de69d | 2010-03-04 14:05:48 +0100 | [diff] [blame] | 56 | .type = FIO_OPT_STR_STORE, |
| 57 | .roff1 = &dir, |
| 58 | .help = "Test directory", |
Jens Axboe | 13fca82 | 2012-03-31 13:55:54 +0200 | [diff] [blame] | 59 | .category = FIO_OPT_C_PROFILE, |
| 60 | .group = FIO_OPT_G_TIOBENCH, |
Jens Axboe | e2de69d | 2010-03-04 14:05:48 +0100 | [diff] [blame] | 61 | }, |
| 62 | { |
Jens Axboe | 2363d8d | 2010-03-04 14:30:02 +0100 | [diff] [blame] | 63 | .name = "threads", |
Jens Axboe | e8b0e95 | 2012-03-19 14:37:08 +0100 | [diff] [blame] | 64 | .lname = "Tiobench threads", |
Jens Axboe | 2363d8d | 2010-03-04 14:30:02 +0100 | [diff] [blame] | 65 | .type = FIO_OPT_INT, |
| 66 | .roff1 = &nthreads, |
| 67 | .help = "Number of Threads", |
Jens Axboe | 13fca82 | 2012-03-31 13:55:54 +0200 | [diff] [blame] | 68 | .category = FIO_OPT_C_PROFILE, |
| 69 | .group = FIO_OPT_G_TIOBENCH, |
Jens Axboe | 2363d8d | 2010-03-04 14:30:02 +0100 | [diff] [blame] | 70 | }, |
| 71 | { |
Jens Axboe | e2de69d | 2010-03-04 14:05:48 +0100 | [diff] [blame] | 72 | .name = NULL, |
| 73 | }, |
| 74 | }; |
| 75 | |
Jens Axboe | 2363d8d | 2010-03-04 14:30:02 +0100 | [diff] [blame] | 76 | /* |
| 77 | * Fill our private options into the command line |
| 78 | */ |
Jens Axboe | d4afedf | 2013-05-22 22:21:29 +0200 | [diff] [blame] | 79 | static int tb_prep_cmdline(void) |
Jens Axboe | 2363d8d | 2010-03-04 14:30:02 +0100 | [diff] [blame] | 80 | { |
Jens Axboe | 2363d8d | 2010-03-04 14:30:02 +0100 | [diff] [blame] | 81 | /* |
| 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 Axboe | d4afedf | 2013-05-22 22:21:29 +0200 | [diff] [blame] | 99 | return 0; |
Jens Axboe | 2363d8d | 2010-03-04 14:30:02 +0100 | [diff] [blame] | 100 | } |
| 101 | |
Jens Axboe | 79d1631 | 2010-03-04 12:43:20 +0100 | [diff] [blame] | 102 | static struct profile_ops tiobench_profile = { |
| 103 | .name = "tiobench", |
Jens Axboe | f5b6bb8 | 2010-03-05 10:09:59 +0100 | [diff] [blame] | 104 | .desc = "tiotest/tiobench benchmark", |
Jens Axboe | e2de69d | 2010-03-04 14:05:48 +0100 | [diff] [blame] | 105 | .options = options, |
Jens Axboe | 2363d8d | 2010-03-04 14:30:02 +0100 | [diff] [blame] | 106 | .prep_cmd = tb_prep_cmdline, |
| 107 | .cmdline = tb_opts, |
Jens Axboe | 79d1631 | 2010-03-04 12:43:20 +0100 | [diff] [blame] | 108 | }; |
| 109 | |
| 110 | static void fio_init tiobench_register(void) |
| 111 | { |
Jens Axboe | 07b3232 | 2010-03-05 09:48:44 +0100 | [diff] [blame] | 112 | if (register_profile(&tiobench_profile)) |
| 113 | log_err("fio: failed to register profile 'tiobench'\n"); |
Jens Axboe | 79d1631 | 2010-03-04 12:43:20 +0100 | [diff] [blame] | 114 | } |
| 115 | |
| 116 | static void fio_exit tiobench_unregister(void) |
| 117 | { |
| 118 | unregister_profile(&tiobench_profile); |
| 119 | } |