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[] = "0.99";
30 char *devices, *exes, *input_name, *output_name, *seek_name;
31 char *d2c_name, *q2c_name, *per_io_name;
32 FILE *ranges_ofp, *avgs_ofp, *per_io_ofp;
33 int verbose, done, time_bounded;
34 double t_astart, t_aend;
35 unsigned long n_traces;
36 struct avgs_info all_avgs;
38 time_t genesis, last_vtrace;
43 double range_delta = 0.1;
44 __u64 last_q = (__u64)-1;
45 __u64 next_retry_check = 0;
47 struct region_info all_regions = {
48 .qranges = LIST_HEAD_INIT(all_regions.qranges),
49 .cranges = LIST_HEAD_INIT(all_regions.cranges),
60 int main(int argc, char *argv[])
62 handle_args(argc, argv);
66 if (process() || output_avgs(avgs_ofp) || output_ranges(ranges_ofp))
72 static inline double tv2dbl(struct timeval *tv)
74 return (double)tv->tv_sec + (((double)tv->tv_usec) / (1000.0 * 1000.0));
80 struct io *iop = io_alloc();
81 struct timeval tvs, tvi, tve;
83 genesis = last_vtrace = time(NULL);
84 gettimeofday(&tvs, NULL);
85 while (!done && next_trace(&iop->t, &iop->pdu)) {
93 gettimeofday(&tvi, NULL);
96 fprintf(iostat_ofp, "\n");
97 iostat_dump_stats(iostat_last_stamp, 1);
102 gettimeofday(&tve, NULL);
105 double tps, dt_input = tv2dbl(&tvi) - tv2dbl(&tvs);
107 tps = (double)n_traces / dt_input;
108 printf("%10lu traces @ %.1lf Ktps\t%.6lf+%.6lf=%.6lf\n",
109 n_traces, tps/1000.0,
110 dt_input, tv2dbl(&tve) - tv2dbl(&tvi),
111 tv2dbl(&tve) - tv2dbl(&tvs));
113 printf("\ttree = |%d|\n", rb_tree_size);
114 if (rb_tree_size > 0)