X-Git-Url: https://git.kernel.dk/?p=fio.git;a=blobdiff_plain;f=stat.c;h=23657cee6a7702c3aacd81783acb1516b3960a1b;hp=efa811d2b70e5c23dd48ace87d19eb925fc31916;hb=87622bf5295880682bfad5ba14116cf5facbaf2c;hpb=839f607b5771081e96942977a1ff9f1b24b77bca diff --git a/stat.c b/stat.c index efa811d2..23657cee 100644 --- a/stat.c +++ b/stat.c @@ -414,6 +414,18 @@ static void display_lat(const char *name, unsigned long long min, free(maxp); } +static double convert_agg_kbytes_percent(struct group_run_stats *rs, int ddir, int mean) +{ + double p_of_agg = 100.0; + if (rs && rs->agg[ddir] > 1024) { + p_of_agg = mean * 100 / (double) (rs->agg[ddir] / 1024.0); + + if (p_of_agg > 100.0) + p_of_agg = 100.0; + } + return p_of_agg; +} + static void show_ddir_status(struct group_run_stats *rs, struct thread_stat *ts, int ddir, struct buf_output *out) { @@ -551,11 +563,7 @@ static void show_ddir_status(struct group_run_stats *rs, struct thread_stat *ts, else bw_str = "kB"; - if (rs->agg[ddir]) { - p_of_agg = mean * 100 / (double) (rs->agg[ddir] / 1024); - if (p_of_agg > 100.0) - p_of_agg = 100.0; - } + p_of_agg = convert_agg_kbytes_percent(rs, ddir, mean); if (rs->unit_base == 1) { min *= 8.0; @@ -1376,11 +1384,7 @@ static void add_ddir_status_json(struct thread_stat *ts, } if (calc_lat(&ts->bw_stat[ddir], &min, &max, &mean, &dev)) { - if (rs->agg[ddir]) { - p_of_agg = mean * 100 / (double) (rs->agg[ddir] / 1024); - if (p_of_agg > 100.0) - p_of_agg = 100.0; - } + p_of_agg = convert_agg_kbytes_percent(rs, ddir, mean); } else { min = max = 0; p_of_agg = mean = dev = 0.0; @@ -1506,12 +1510,8 @@ static void json_add_job_opts(struct json_object *root, const char *name, json_object_add_value_object(root, name, dir_object); flist_for_each(entry, opt_list) { - const char *pos = ""; - p = flist_entry(entry, struct print_option, list); - if (p->value) - pos = p->value; - json_object_add_value_string(dir_object, p->name, pos); + json_object_add_value_string(dir_object, p->name, p->value); } } @@ -2354,8 +2354,6 @@ void __show_running_run_stats(void) fio_sem_up(stat_sem); } -static bool status_interval_init; -static struct timespec status_time; static bool status_file_disabled; #define FIO_STATUS_FILE "fio-dump-status" @@ -2398,16 +2396,6 @@ static int check_status_file(void) void check_for_running_stats(void) { - if (status_interval) { - if (!status_interval_init) { - fio_gettime(&status_time, NULL); - status_interval_init = true; - } else if (mtime_since_now(&status_time) >= status_interval) { - show_running_run_stats(); - fio_gettime(&status_time, NULL); - return; - } - } if (check_status_file()) { show_running_run_stats(); return; @@ -3146,3 +3134,4 @@ uint32_t *io_u_block_info(struct thread_data *td, struct io_u *io_u) assert(idx < td->ts.nr_block_infos); return info; } +