diff options
author | Bjoern B. Brandenburg <bbb@cs.unc.edu> | 2008-09-22 17:20:16 -0400 |
---|---|---|
committer | Bjoern B. Brandenburg <bbb@cs.unc.edu> | 2008-09-22 17:20:16 -0400 |
commit | 956ffd54dda4da2f6d7c0963fda54a6be95f1c4f (patch) | |
tree | 955dc1179211dfffa3905491cdff86737190bca5 /src/ft2csv.c | |
parent | a8b90fadf3b8cb67ef881a072f9f283d2a7a51af (diff) | |
parent | 00de6faa7cf1a9e95d738b204f570dd7123e738e (diff) |
Merge branch 'master' of git+ssh://cvs/cvs/proj/litmus/repo/ft_tools
Diffstat (limited to 'src/ft2csv.c')
-rw-r--r-- | src/ft2csv.c | 147 |
1 files changed, 61 insertions, 86 deletions
diff --git a/src/ft2csv.c b/src/ft2csv.c index a19d2f2..2cd417c 100644 --- a/src/ft2csv.c +++ b/src/ft2csv.c | |||
@@ -7,55 +7,70 @@ | |||
7 | 7 | ||
8 | #include "timestamp.h" | 8 | #include "timestamp.h" |
9 | 9 | ||
10 | int no_interleaved = 1; | ||
11 | |||
10 | static unsigned int complete = 0; | 12 | static unsigned int complete = 0; |
11 | static unsigned int incomplete = 0; | 13 | static unsigned int incomplete = 0; |
12 | static unsigned int filtered = 0; | 14 | static unsigned int filtered = 0; |
13 | static unsigned int skipped = 0; | 15 | static unsigned int skipped = 0; |
14 | static unsigned int non_rt = 0; | 16 | static unsigned int non_rt = 0; |
17 | static unsigned int interleaved = 0; | ||
15 | 18 | ||
16 | static unsigned long long threshold = 2700 * 1000; /* 1 ms == 1 full tick */ | 19 | static unsigned long long threshold = 2700 * 1000; /* 1 ms == 1 full tick */ |
17 | //static unsigned long long threshold = 2700 * 50; /* 1 ms == 1 full tick */ | 20 | //static unsigned long long threshold = 2700 * 50; /* 1 ms == 1 full tick */ |
18 | 21 | ||
19 | static struct timestamp* next(struct timestamp** pos, size_t* count, int cpu) | 22 | static struct timestamp* next(struct timestamp* start, struct timestamp* end, |
23 | int cpu) | ||
20 | { | 24 | { |
21 | while (*count--) | 25 | struct timestamp* pos; |
22 | if ((++(*pos))->cpu == cpu) | 26 | for (pos = start; pos != end && pos->cpu != cpu; pos++); |
23 | return *pos; | 27 | return pos != end ? pos : NULL; |
24 | return NULL; | ||
25 | } | 28 | } |
26 | 29 | ||
27 | static struct timestamp* next_id(struct timestamp** pos, size_t* count, | 30 | static struct timestamp* next_id(struct timestamp* start, struct timestamp* end, |
28 | int cpu, unsigned long id) | 31 | int cpu, unsigned long id, unsigned long stop_id) |
29 | { | 32 | { |
30 | struct timestamp* ret; | 33 | struct timestamp* pos = start; |
31 | while ((ret = next(pos, count, cpu)) && (*pos)->event != id); | 34 | int restarts = 0; |
32 | return ret; | 35 | |
36 | while ((pos = next(pos, end, cpu))) { | ||
37 | if (pos->event == id) | ||
38 | break; | ||
39 | else if (pos->event == stop_id) | ||
40 | return NULL; | ||
41 | pos++; | ||
42 | restarts++; | ||
43 | if (no_interleaved) | ||
44 | return NULL; | ||
45 | } | ||
46 | if (pos) | ||
47 | interleaved += restarts; | ||
48 | return pos; | ||
33 | } | 49 | } |
34 | 50 | ||
35 | static int find_pair(struct timestamp* start, | 51 | static struct timestamp* find_second_ts(struct timestamp* start, struct timestamp* end) |
36 | struct timestamp** end, | ||
37 | size_t count) | ||
38 | { | 52 | { |
39 | struct timestamp *pos = start; | ||
40 | /* convention: the end->event is start->event + 1 */ | 53 | /* convention: the end->event is start->event + 1 */ |
41 | *end = next_id(&pos, &count, start->cpu, start->event + 1); | 54 | return next_id(start + 1, end, start->cpu, start->event + 1, start->event); |
42 | return *end != NULL; | ||
43 | } | 55 | } |
44 | 56 | ||
45 | static void show_csv(struct timestamp* ts, size_t count) | 57 | static void show_csv(struct timestamp* first, struct timestamp *end) |
46 | { | 58 | { |
47 | struct timestamp* start = ts; | 59 | struct timestamp *second; |
48 | struct timestamp* stop; | ||
49 | 60 | ||
50 | if (find_pair(start, &stop, count)) { | 61 | second = find_second_ts(first, end); |
51 | if (stop->timestamp - start->timestamp > threshold) | 62 | if (second) { |
63 | if (second->timestamp - first->timestamp > threshold) | ||
52 | filtered++; | 64 | filtered++; |
53 | else if (start->task_type != TSK_RT && stop->task_type != TSK_RT) | 65 | else if (first->task_type != TSK_RT && |
66 | second->task_type != TSK_RT) | ||
54 | non_rt++; | 67 | non_rt++; |
55 | else { | 68 | else { |
56 | printf("%llu, %llu, %llu\n", | 69 | printf("%llu, %llu, %llu\n", |
57 | start->timestamp, stop->timestamp, | 70 | (unsigned long long) first->timestamp, |
58 | stop->timestamp - start->timestamp); | 71 | (unsigned long long) second->timestamp, |
72 | (unsigned long long) | ||
73 | (second->timestamp - first->timestamp)); | ||
59 | complete++; | 74 | complete++; |
60 | } | 75 | } |
61 | } else | 76 | } else |
@@ -63,62 +78,19 @@ static void show_csv(struct timestamp* ts, size_t count) | |||
63 | 78 | ||
64 | } | 79 | } |
65 | 80 | ||
66 | /*static void show_all_per_cpu(struct timestamp* ts, size_t count) | 81 | static void show_id(struct timestamp* start, struct timestamp* end, |
82 | unsigned long id) | ||
67 | { | 83 | { |
68 | struct timestamp* _ts = ts; | 84 | while (start !=end && start->event != id + 1) { |
69 | size_t _count = count; | ||
70 | int cpu; | ||
71 | |||
72 | for (cpu = 0; cpu < 4; cpu++) { | ||
73 | count = _count; | ||
74 | ts = _ts; | ||
75 | while (count--) { | ||
76 | if (ts->cpu == cpu) | ||
77 | show(ts, count); | ||
78 | ts++; | ||
79 | } | ||
80 | } | ||
81 | }*/ | ||
82 | |||
83 | |||
84 | static void skip_n(struct timestamp** ts, size_t *count, unsigned int n) | ||
85 | { | ||
86 | while (n-- && (*count)--) | ||
87 | { | ||
88 | (*ts)++; | ||
89 | skipped++; | 85 | skipped++; |
86 | start++; | ||
90 | } | 87 | } |
91 | } | ||
92 | 88 | ||
93 | static void show_id(struct timestamp* ts, size_t count, unsigned long id) | 89 | for (; start != end; start++) |
94 | { | 90 | if (start->event == id) |
95 | while (ts->event != id + 1 && count) { | 91 | show_csv(start, end); |
96 | skipped++; | ||
97 | ts++; | ||
98 | count--; | ||
99 | } | ||
100 | //printf("count == %d\n", count); | ||
101 | if (!count) | ||
102 | return; | ||
103 | skip_n(&ts, &count, 100); | ||
104 | if (!count) | ||
105 | return; | ||
106 | //printf("count == %d\n", count); | ||
107 | while (count--) | ||
108 | if (ts->event == id) | ||
109 | show_csv(ts++, count); | ||
110 | else | ||
111 | ts++; | ||
112 | } | ||
113 | |||
114 | |||
115 | static void dump(struct timestamp* ts, size_t count, unsigned long id) | ||
116 | { | ||
117 | while (count--) | ||
118 | printf("%lu\n", (ts++)->event); | ||
119 | } | 92 | } |
120 | 93 | ||
121 | |||
122 | static void die(char* msg) | 94 | static void die(char* msg) |
123 | { | 95 | { |
124 | if (errno) | 96 | if (errno) |
@@ -131,8 +103,8 @@ int main(int argc, char** argv) | |||
131 | { | 103 | { |
132 | void* mapped; | 104 | void* mapped; |
133 | size_t size, count; | 105 | size_t size, count; |
134 | struct timestamp* ts; | 106 | struct timestamp *ts, *end; |
135 | unsigned long id; | 107 | cmd_t id; |
136 | 108 | ||
137 | if (argc != 3) | 109 | if (argc != 3) |
138 | die("Usage: ft2csv <event_name> <logfile>"); | 110 | die("Usage: ft2csv <event_name> <logfile>"); |
@@ -143,20 +115,23 @@ int main(int argc, char** argv) | |||
143 | die("Unknown event!"); | 115 | die("Unknown event!"); |
144 | 116 | ||
145 | ts = (struct timestamp*) mapped; | 117 | ts = (struct timestamp*) mapped; |
146 | count = size / sizeof(struct timestamp); | 118 | count = size / sizeof(struct timestamp); |
119 | end = ts + count; | ||
147 | 120 | ||
148 | show_id(ts, count, id); | 121 | show_id(ts, end, id); |
149 | 122 | ||
150 | fprintf(stderr, | 123 | fprintf(stderr, |
151 | "Total : %10d\n" | 124 | "Total : %10d\n" |
152 | "Skipped : %10d\n" | 125 | "Skipped : %10d\n" |
153 | "Complete : %10d\n" | 126 | "Complete : %10d\n" |
154 | "Incomplete: %10d\n" | 127 | "Incomplete : %10d\n" |
155 | "Filtered : %10d\n" | 128 | "Filtered : %10d\n" |
156 | "Non RT : %10d\n", | 129 | "Non RT : %10d\n" |
157 | count, | 130 | "Interleaved : %10d\n", |
131 | (int) count, | ||
158 | skipped, complete, | 132 | skipped, complete, |
159 | incomplete, filtered, non_rt); | 133 | incomplete, filtered, non_rt, |
134 | interleaved); | ||
160 | 135 | ||
161 | return 0; | 136 | return 0; |
162 | } | 137 | } |