Commit | Line | Data |
---|---|---|
b2ecdd0f ADB |
1 | /* |
2 | * blktrace output analysis: generate a timeline & gather statistics | |
3 | * | |
4 | * Copyright (C) 2006 Alan D. Brunelle <Alan.Brunelle@hp.com> | |
5 | * | |
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. | |
10 | * | |
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. | |
15 | * | |
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 | |
19 | * | |
20 | */ | |
21 | #include "globals.h" | |
22 | ||
b2ecdd0f ADB |
23 | static inline void latency_out(FILE *ofp, __u64 tstamp, __u64 latency) |
24 | { | |
25 | if (ofp) | |
26 | fprintf(ofp, "%lf %lf\n", TO_SEC(tstamp), TO_SEC(latency)); | |
27 | } | |
28 | ||
a155ab98 | 29 | FILE *latency_open(struct d_info *dip, char *name, char *post) |
b2ecdd0f | 30 | { |
c053af42 | 31 | FILE *fp = NULL; |
b2ecdd0f | 32 | |
c053af42 | 33 | if (name) { |
a155ab98 AB |
34 | size_t tlen = strlen(name) + strlen(dip->dip_name) |
35 | + strlen(post) + 32; | |
36 | char oname[tlen]; | |
b2ecdd0f | 37 | |
a155ab98 | 38 | sprintf(oname, "%s_%s_%s.dat", name, dip->dip_name, post); |
c053af42 AB |
39 | if ((fp = my_fopen(oname, "w")) == NULL) |
40 | perror(oname); | |
41 | else | |
42 | add_file(fp, strdup(oname)); | |
43 | } | |
b2ecdd0f ADB |
44 | |
45 | return fp; | |
46 | } | |
47 | ||
c053af42 | 48 | void latency_alloc(struct d_info *dip) |
b2ecdd0f | 49 | { |
a155ab98 AB |
50 | dip->q2d_ofp = latency_open(dip, q2d_name, "q2d"); |
51 | dip->d2c_ofp = latency_open(dip, d2c_name, "d2c"); | |
52 | dip->q2c_ofp = latency_open(dip, q2c_name, "q2c"); | |
b2ecdd0f ADB |
53 | } |
54 | ||
e47ada10 AB |
55 | void latency_q2d(struct d_info *dip, __u64 tstamp, __u64 latency) |
56 | { | |
57 | plat_x2c(dip->q2d_plat_handle, tstamp, latency); | |
58 | latency_out(dip->q2d_ofp, tstamp, latency); | |
59 | } | |
60 | ||
b2ecdd0f ADB |
61 | void latency_d2c(struct d_info *dip, __u64 tstamp, __u64 latency) |
62 | { | |
2baef508 | 63 | plat_x2c(dip->d2c_plat_handle, tstamp, latency); |
b2ecdd0f ADB |
64 | latency_out(dip->d2c_ofp, tstamp, latency); |
65 | } | |
66 | ||
67 | void latency_q2c(struct d_info *dip, __u64 tstamp, __u64 latency) | |
68 | { | |
2baef508 | 69 | plat_x2c(dip->q2c_plat_handle, tstamp, latency); |
b2ecdd0f ADB |
70 | latency_out(dip->q2c_ofp, tstamp, latency); |
71 | } |