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", |
| 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 | |
Jens Axboe | e2de69d | 2010-03-04 14:05:48 +0100 | [diff] [blame] | 23 | static struct fio_option options[] = { |
| 24 | { |
| 25 | .name = "size", |
Jens Axboe | 2363d8d | 2010-03-04 14:30:02 +0100 | [diff] [blame] | 26 | .type = FIO_OPT_STR_VAL, |
Jens Axboe | e2de69d | 2010-03-04 14:05:48 +0100 | [diff] [blame] | 27 | .roff1 = &size, |
| 28 | .help = "Size in MB", |
| 29 | }, |
| 30 | { |
| 31 | .name = "block", |
| 32 | .type = FIO_OPT_INT, |
| 33 | .roff1 = &bs, |
| 34 | .help = "Block size in bytes", |
| 35 | .def = "4k", |
| 36 | }, |
| 37 | { |
| 38 | .name = "numruns", |
| 39 | .type = FIO_OPT_INT, |
| 40 | .roff1 = &loops, |
| 41 | .help = "Number of runs", |
| 42 | }, |
| 43 | { |
| 44 | .name = "dir", |
| 45 | .type = FIO_OPT_STR_STORE, |
| 46 | .roff1 = &dir, |
| 47 | .help = "Test directory", |
| 48 | }, |
| 49 | { |
Jens Axboe | 2363d8d | 2010-03-04 14:30:02 +0100 | [diff] [blame] | 50 | .name = "threads", |
| 51 | .type = FIO_OPT_INT, |
| 52 | .roff1 = &nthreads, |
| 53 | .help = "Number of Threads", |
| 54 | }, |
| 55 | { |
Jens Axboe | e2de69d | 2010-03-04 14:05:48 +0100 | [diff] [blame] | 56 | .name = NULL, |
| 57 | }, |
| 58 | }; |
| 59 | |
Jens Axboe | 2363d8d | 2010-03-04 14:30:02 +0100 | [diff] [blame] | 60 | /* |
| 61 | * Fill our private options into the command line |
| 62 | */ |
| 63 | static void tb_prep_cmdline(void) |
| 64 | { |
| 65 | |
| 66 | /* |
| 67 | * tiobench uses size as MB, so multiply up |
| 68 | */ |
| 69 | size *= 1024 * 1024ULL; |
| 70 | if (size) |
| 71 | sprintf(sz_idx, "size=%llu", size); |
| 72 | else |
| 73 | strcpy(sz_idx, "size=4*1024*$mb_memory"); |
| 74 | |
| 75 | sprintf(bs_idx, "bs=%u", bs); |
| 76 | sprintf(loop_idx, "loops=%u", loops); |
| 77 | |
| 78 | if (dir) |
| 79 | sprintf(dir_idx, "directory=%s", dir); |
| 80 | else |
| 81 | sprintf(dir_idx, "directory=./"); |
| 82 | |
| 83 | sprintf(t_idx, "numjobs=%u", nthreads); |
| 84 | } |
| 85 | |
Jens Axboe | 79d1631 | 2010-03-04 12:43:20 +0100 | [diff] [blame] | 86 | static struct profile_ops tiobench_profile = { |
| 87 | .name = "tiobench", |
Jens Axboe | f5b6bb8 | 2010-03-05 10:09:59 +0100 | [diff] [blame] | 88 | .desc = "tiotest/tiobench benchmark", |
Jens Axboe | e2de69d | 2010-03-04 14:05:48 +0100 | [diff] [blame] | 89 | .options = options, |
Jens Axboe | 2363d8d | 2010-03-04 14:30:02 +0100 | [diff] [blame] | 90 | .prep_cmd = tb_prep_cmdline, |
| 91 | .cmdline = tb_opts, |
Jens Axboe | 79d1631 | 2010-03-04 12:43:20 +0100 | [diff] [blame] | 92 | }; |
| 93 | |
| 94 | static void fio_init tiobench_register(void) |
| 95 | { |
Jens Axboe | 07b3232 | 2010-03-05 09:48:44 +0100 | [diff] [blame] | 96 | if (register_profile(&tiobench_profile)) |
| 97 | log_err("fio: failed to register profile 'tiobench'\n"); |
Jens Axboe | 79d1631 | 2010-03-04 12:43:20 +0100 | [diff] [blame] | 98 | } |
| 99 | |
| 100 | static void fio_exit tiobench_unregister(void) |
| 101 | { |
| 102 | unregister_profile(&tiobench_profile); |
| 103 | } |