diff options
author | Bjoern B. Brandenburg <bbb@cs.unc.edu> | 2010-03-10 14:13:54 -0500 |
---|---|---|
committer | Bjoern B. Brandenburg <bbb@cs.unc.edu> | 2010-03-10 14:13:54 -0500 |
commit | d4da00e0c66d7143759a91925c3027fc54ba8234 (patch) | |
tree | 9d9dc32c0c96ea550bad698ca9de462a677a32a2 | |
parent | b1096b601d7dab3aba29a68cdf161505100bd55a (diff) |
add -f option to st_show
-f causes it to interpret the first task event (if any)
as the system release.
-rw-r--r-- | src/showst.c | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/src/showst.c b/src/showst.c index a89da10..91e036b 100644 --- a/src/showst.c +++ b/src/showst.c | |||
@@ -15,6 +15,8 @@ static void usage(const char *str) | |||
15 | "\n" | 15 | "\n" |
16 | " OPTIONS\n" | 16 | " OPTIONS\n" |
17 | " -r -- find task system release and exit\n" | 17 | " -r -- find task system release and exit\n" |
18 | " -f -- use first non-zero event as system release\n" | ||
19 | " if no system release event is found\n" | ||
18 | " -c -- display a count of the number of events\n" | 20 | " -c -- display a count of the number of events\n" |
19 | "\n\n" | 21 | "\n\n" |
20 | ); | 22 | ); |
@@ -22,17 +24,18 @@ static void usage(const char *str) | |||
22 | exit(1); | 24 | exit(1); |
23 | } | 25 | } |
24 | 26 | ||
25 | #define OPTSTR "rc" | 27 | #define OPTSTR "rcf" |
26 | 28 | ||
27 | int main(int argc, char** argv) | 29 | int main(int argc, char** argv) |
28 | { | 30 | { |
29 | unsigned int count; | 31 | unsigned int count; |
30 | struct heap *h; | 32 | struct heap *h; |
31 | struct heap_node *hn; | 33 | struct heap_node *hn, *first = NULL; |
32 | u64 time; | 34 | u64 time; |
33 | struct st_event_record *rec; | 35 | struct st_event_record *rec; |
34 | int find_release = 0; | 36 | int find_release = 0; |
35 | int show_count = 0; | 37 | int show_count = 0; |
38 | int use_first_nonzero = 0; | ||
36 | int opt; | 39 | int opt; |
37 | 40 | ||
38 | while ((opt = getopt(argc, argv, OPTSTR)) != -1) { | 41 | while ((opt = getopt(argc, argv, OPTSTR)) != -1) { |
@@ -43,6 +46,9 @@ int main(int argc, char** argv) | |||
43 | case 'c': | 46 | case 'c': |
44 | show_count = 1; | 47 | show_count = 1; |
45 | break; | 48 | break; |
49 | case 'f': | ||
50 | use_first_nonzero = 1; | ||
51 | break; | ||
46 | case ':': | 52 | case ':': |
47 | usage("Argument missing."); | 53 | usage("Argument missing."); |
48 | break; | 54 | break; |
@@ -61,6 +67,8 @@ int main(int argc, char** argv) | |||
61 | printf("Loaded %u events.\n", count); | 67 | printf("Loaded %u events.\n", count); |
62 | while ((hn = heap_take(earlier_event, h))) { | 68 | while ((hn = heap_take(earlier_event, h))) { |
63 | time = event_time(heap_node_value(hn)); | 69 | time = event_time(heap_node_value(hn)); |
70 | if (time != 0 && !first) | ||
71 | first = hn; | ||
64 | time /= 1000000; /* convert to milliseconds */ | 72 | time /= 1000000; /* convert to milliseconds */ |
65 | if (!find_release) { | 73 | if (!find_release) { |
66 | printf("[%10llu] ", (unsigned long long) time); | 74 | printf("[%10llu] ", (unsigned long long) time); |
@@ -69,10 +77,15 @@ int main(int argc, char** argv) | |||
69 | rec = heap_node_value(hn); | 77 | rec = heap_node_value(hn); |
70 | if (rec->hdr.type == ST_SYS_RELEASE) { | 78 | if (rec->hdr.type == ST_SYS_RELEASE) { |
71 | printf("%6.2fms\n", rec->data.raw[1] / 1000000.0); | 79 | printf("%6.2fms\n", rec->data.raw[1] / 1000000.0); |
80 | find_release = 0; | ||
72 | break; | 81 | break; |
73 | } | 82 | } |
74 | } | 83 | } |
75 | } | 84 | } |
85 | if (find_release && use_first_nonzero && first) { | ||
86 | rec = heap_node_value(first); | ||
87 | printf("%6.2fms\n", event_time(rec) / 1000000.0); | ||
88 | } | ||
76 | 89 | ||
77 | return 0; | 90 | return 0; |
78 | } | 91 | } |