2 * blktrace output analysis: generate a timeline & gather statistics
4 * Copyright (C) 2006 Alan D. Brunelle <Alan.Brunelle@hp.com>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 char bt_timeline_version[] = "2.09";
30 char *devices, *exes, *input_name, *output_name, *seek_name, *bno_dump_name;
31 char *d2c_name, *q2c_name, *per_io_name, *unplug_hist_name;
32 char *sps_name, *aqd_name, *q2d_name, *per_io_trees;
33 FILE *rngs_ofp, *avgs_ofp, *xavgs_ofp, *per_io_ofp, *msgs_ofp;
34 int verbose, done, time_bounded, output_all_data, seek_absolute;
35 int easy_parse_avgs, ignore_remaps, do_p_live;
36 double t_astart, t_aend, last_t_seen;
37 unsigned long n_traces;
38 struct avgs_info all_avgs;
40 time_t genesis, last_vtrace;
45 LIST_HEAD(free_bilinks);
46 __u64 q_histo[N_HIST_BKTS], d_histo[N_HIST_BKTS];
48 double plat_freq = 0.0;
49 double range_delta = 0.1;
50 __u64 last_q = (__u64)-1;
52 struct region_info all_regions = {
53 .qranges = LIST_HEAD_INIT(all_regions.qranges),
54 .cranges = LIST_HEAD_INIT(all_regions.cranges),
59 int main(int argc, char *argv[])
61 handle_args(argc, argv);
68 if (process() || output_avgs(avgs_ofp) || output_ranges(rngs_ofp))
72 fprintf(iostat_ofp, "\n");
73 iostat_dump_stats(iostat_last_stamp, 1);
76 if (msgs_ofp != stdout)
78 if (rngs_ofp != stdout)
80 if (avgs_ofp != stdout)
91 region_exit(&all_regions);
98 static inline double tv2dbl(struct timeval *tv)
100 return (double)tv->tv_sec + (((double)tv->tv_usec) / (1000.0 * 1000.0));
106 struct io *iop = io_alloc();
107 struct timeval tvs, tve;
109 genesis = last_vtrace = time(NULL);
110 gettimeofday(&tvs, NULL);
111 while (!done && next_trace(&iop->t, &iop->pdu)) {
117 gettimeofday(&tve, NULL);
120 double tps, dt_input = tv2dbl(&tve) - tv2dbl(&tvs);
122 tps = (double)n_traces / dt_input;
125 printf("%10lu traces @ %.1lf Ktps in %.6lf seconds\n",
126 n_traces, tps/1000.0,