Added in running stats for btt
[blktrace.git] / btt / bt_timeline.c
index e9407e0b02cacdc010921cc45c9471381c8d4076..9b0850b8729c511493e6c3e3563fbefae7dfe6d7 100644 (file)
 #include <time.h>
 #include "globals.h"
 
-char bt_timeline_version[] = "0.99.1";
-
-char *devices, *exes, *input_name, *output_name, *seek_name;
-char *d2c_name, *q2c_name, *per_io_name;
-FILE *ranges_ofp, *avgs_ofp, *per_io_ofp;
-int verbose, done, time_bounded, output_all_data;
-double t_astart, t_aend;
+char bt_timeline_version[] = "2.08";
+
+char *devices, *exes, *input_name, *output_name, *seek_name, *bno_dump_name;
+char *d2c_name, *q2c_name, *per_io_name, *unplug_hist_name;
+char *sps_name, *aqd_name, *q2d_name, *per_io_trees;
+FILE *rngs_ofp, *avgs_ofp, *xavgs_ofp, *per_io_ofp, *msgs_ofp;
+int verbose, done, time_bounded, output_all_data, seek_absolute;
+int easy_parse_avgs, ignore_remaps;
+double t_astart, t_aend, last_t_seen;
 unsigned long n_traces;
 struct avgs_info all_avgs;
 unsigned int n_devs;
 time_t genesis, last_vtrace;
 LIST_HEAD(all_devs);
 LIST_HEAD(all_procs);
+LIST_HEAD(all_ios);
 LIST_HEAD(free_ios);
-LIST_HEAD(rmhd);
-LIST_HEAD(retries);
+LIST_HEAD(free_bilinks);
 __u64 q_histo[N_HIST_BKTS], d_histo[N_HIST_BKTS];
 
+double plat_freq = 0.0;
 double range_delta = 0.1;
 __u64 last_q = (__u64)-1;
-__u64 next_retry_check = 0;
 
 struct region_info all_regions = {
        .qranges = LIST_HEAD_INIT(all_regions.qranges),
        .cranges = LIST_HEAD_INIT(all_regions.cranges),
-       .qr_cur = NULL,
-       .cr_cur = NULL
 };
 
-#if defined(DEBUG)
-       int rb_tree_size;
-#endif
-
-#if defined(COUNT_IOS)
-unsigned long nios_reused, nios_alloced, nios_freed;
-LIST_HEAD(cios);
-#endif
-
 int process(void);
 
 int main(int argc, char *argv[])
@@ -71,9 +62,35 @@ int main(int argc, char *argv[])
 
        init_dev_heads();
        iostat_init();
-       if (process() || output_avgs(avgs_ofp) || output_ranges(ranges_ofp))
+       if (!rstat_init())
+               return 1;
+
+       if (process() || output_avgs(avgs_ofp) || output_ranges(rngs_ofp))
                return 1;
 
+       if (iostat_ofp) {
+               fprintf(iostat_ofp, "\n");
+               iostat_dump_stats(iostat_last_stamp, 1);
+       }
+
+       if (msgs_ofp != stdout)
+               fclose(msgs_ofp);
+       if (rngs_ofp != stdout)
+               fclose(rngs_ofp);
+       if (avgs_ofp != stdout)
+               fclose(avgs_ofp);
+       if (xavgs_ofp)
+               fclose(xavgs_ofp);
+
+       dip_cleanup();
+       dev_map_exit();
+       dip_exit();
+       rstat_exit();
+       pip_exit();
+       io_free_all();
+       region_exit(&all_regions);
+       clean_allocs();
+
        return 0;
 }
 
@@ -86,7 +103,7 @@ int process(void)
 {
        int ret = 0;
        struct io *iop = io_alloc();
-       struct timeval tvs, tvi, tve;
+       struct timeval tvs, tve;
 
        genesis = last_vtrace = time(NULL);
        gettimeofday(&tvs, NULL);
@@ -96,54 +113,17 @@ int process(void)
        }
 
        io_release(iop);
-       do_retries(0);
-
-       gettimeofday(&tvi, NULL);
-
-       if (iostat_ofp) {
-               fprintf(iostat_ofp, "\n");
-               iostat_dump_stats(iostat_last_stamp, 1);
-       }
-
-       seek_clean();
-       latency_clean();
        gettimeofday(&tve, NULL);
 
        if (verbose) {
-               double tps, dt_input = tv2dbl(&tvi) - tv2dbl(&tvs);
-               
+               double tps, dt_input = tv2dbl(&tve) - tv2dbl(&tvs);
+
                tps = (double)n_traces / dt_input;
-               printf("%10lu traces @ %.1lf Ktps\t%.6lf+%.6lf=%.6lf\n", 
+               printf("\r                                        "
+                      "                                        \r");
+               printf("%10lu traces @ %.1lf Ktps in %.6lf seconds\n",
                        n_traces, tps/1000.0,
-                       dt_input, tv2dbl(&tve) - tv2dbl(&tvi),
-                       tv2dbl(&tve) - tv2dbl(&tvs));
-
-#              if defined(DEBUG)
-                       printf("\ttree = |%d|\n", rb_tree_size);
-                       if (rb_tree_size > 0)
-                               dump_rb_trees();
-#              endif
-
-#              if defined(COUNT_IOS)
-                       {
-                               struct io *_iop;
-                               struct list_head *_p;
-                               FILE *_ofp = fopen("cios.txt", "w");
-                               printf("(%ld + %ld) = %ld - %ld = %ld\n", 
-                                       nios_alloced, nios_reused, 
-                                       nios_alloced + nios_reused, 
-                                       nios_freed, 
-                                       (nios_alloced + nios_reused) 
-                                                               - nios_freed);
-
-                               __list_for_each(_p, &cios) {
-                                       _iop = list_entry(_p, struct io, 
-                                                               cio_head);
-                                       __dump_iop(_ofp, _iop, 0);
-                               }
-                               fclose(_ofp);
-                       }
-#              endif
+                       dt_input);
        }
 
        return ret;