Merge branch 'master' of ssh://router/data/git/fio
[fio.git] / options.c
index dda7cba1bdf16b17f6ea009b722ce8ed79ecc38c..bdb56d3e4bec652a58b8f2fe02bdb78656f62fca 100644 (file)
--- a/options.c
+++ b/options.c
@@ -225,6 +225,15 @@ static int str_mem_cb(void *data, const char *mem)
        return 0;
 }
 
+static int fio_clock_source_cb(void *data, const char *str)
+{
+       struct thread_data *td = data;
+
+       fio_clock_source = td->o.clocksource;
+       fio_time_init();
+       return 0;
+}
+
 static int str_lockmem_cb(void fio_unused *data, unsigned long *val)
 {
        mlock_size = *val;
@@ -429,6 +438,7 @@ static int str_fst_cb(void *data, const char *str)
        return 0;
 }
 
+#ifdef FIO_HAVE_SYNC_FILE_RANGE
 static int str_sfr_cb(void *data, const char *str)
 {
        struct thread_data *td = data;
@@ -442,6 +452,7 @@ static int str_sfr_cb(void *data, const char *str)
 
        return 0;
 }
+#endif
 
 static int check_dir(struct thread_data *td, char *fname)
 {
@@ -1214,6 +1225,30 @@ static struct fio_option options[FIO_MAX_OPTS] = {
                .off1   = td_var_offset(ramp_time),
                .help   = "Ramp up time before measuring performance",
        },
+       {
+               .name   = "clocksource",
+               .type   = FIO_OPT_STR,
+               .cb     = fio_clock_source_cb,
+               .off1   = td_var_offset(clocksource),
+               .help   = "What type of timing source to use",
+               .def    = "gettimeofday",
+               .posval = {
+                         { .ival = "gettimeofday",
+                           .oval = CS_GTOD,
+                           .help = "Use gettimeofday(2) for timing",
+                         },
+                         { .ival = "clock_gettime",
+                           .oval = CS_CGETTIME,
+                           .help = "Use clock_gettime(2) for timing",
+                         },
+#ifdef ARCH_HAVE_CPU_CLOCK
+                         { .ival = "cpu",
+                           .oval = CS_CPUCLOCK,
+                           .help = "Use CPU private clock",
+                         },
+#endif
+               },
+       },
        {
                .name   = "mem",
                .alias  = "iomem",