diff options
author | Alan David Brunelle <Alan.Brunelle@hp.com> | 2006-09-21 09:17:43 +0200 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2006-09-21 09:17:43 +0200 |
commit | b2ecdd0fc9f93e7a2bea09dcd7b2c472eb4e0d94 (patch) | |
tree | 7c47d98a76786d4c42d1ed82a245395804c87234 /btt/latency.c | |
parent | 80c27cbe67449fb2e4bdb682002d87f2f0c07e72 (diff) | |
download | blktrace-b2ecdd0fc9f93e7a2bea09dcd7b2c472eb4e0d94.tar.gz blktrace-b2ecdd0fc9f93e7a2bea09dcd7b2c472eb4e0d94.tar.bz2 |
[PATCH] Added in Q2C and D2C latency output option.
Also: cleaned up empty seek and latency files on exit.
Signed-off-by: Alan D. Brunelle <Alan.Brunelle@hp.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'btt/latency.c')
-rw-r--r-- | btt/latency.c | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/btt/latency.c b/btt/latency.c new file mode 100644 index 0000000..916f566 --- /dev/null +++ b/btt/latency.c @@ -0,0 +1,71 @@ +/* + * blktrace output analysis: generate a timeline & gather statistics + * + * Copyright (C) 2006 Alan D. Brunelle <Alan.Brunelle@hp.com> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ +#include "globals.h" + +static struct file_info *all_files = NULL; + +static inline void latency_out(FILE *ofp, __u64 tstamp, __u64 latency) +{ + if (ofp) + fprintf(ofp, "%lf %lf\n", TO_SEC(tstamp), TO_SEC(latency)); +} + +FILE *latency_open(__u32 device, char *name, char *post) +{ + FILE *fp; + char *oname; + int mjr, mnr; + + if (name == NULL) return NULL; + + mjr = device >> MINORBITS; + mnr = device & ((1 << MINORBITS) - 1); + + oname = malloc(strlen(name)+32); + sprintf(oname, "%s_%03d,%03d_%s.dat", name, mjr, mnr, post); + if ((fp = fopen(oname, "w")) == NULL) + perror(oname); + else + add_file(&all_files, fp, oname); + + return fp; +} + +void latency_init(struct d_info *dip) +{ + dip->d2c_ofp = latency_open(dip->device, d2c_name, "d2c"); + dip->q2c_ofp = latency_open(dip->device, q2c_name, "q2c"); +} + +void latency_clean(void) +{ + clean_files(&all_files); +} + +void latency_d2c(struct d_info *dip, __u64 tstamp, __u64 latency) +{ + latency_out(dip->d2c_ofp, tstamp, latency); +} + +void latency_q2c(struct d_info *dip, __u64 tstamp, __u64 latency) +{ + latency_out(dip->q2c_ofp, tstamp, latency); +} |