Last change
on this file since 503c350 was
812ba3d,
checked in by Andrew Beach <ajbeach@…>, 3 years ago
|
Some clean-up to make Peter's changes to the exception benchmarks fit in better. And make test.sh a bit more robust.
|
-
Property mode set to
100644
|
File size:
1002 bytes
|
Line | |
---|
1 | // Resume Across Empty Function |
---|
2 | #include <clock.hfa> |
---|
3 | #include <exception.hfa> |
---|
4 | #include <fstream.hfa> |
---|
5 | #include <stdlib.hfa> |
---|
6 | |
---|
7 | exception fixup_exception { |
---|
8 | int & fixup; |
---|
9 | }; |
---|
10 | vtable(fixup_exception) fixup_vt; |
---|
11 | |
---|
12 | void nounwind_empty(unsigned int frames) { |
---|
13 | if (frames) { |
---|
14 | nounwind_empty(frames - 1); |
---|
15 | // "Always" false, but prevents recursion elimination. |
---|
16 | if (-1 == frames) printf("~"); |
---|
17 | } else { |
---|
18 | int fixup = 17; |
---|
19 | throwResume (fixup_exception){&fixup_vt, fixup}; |
---|
20 | } |
---|
21 | } |
---|
22 | |
---|
23 | int main(int argc, char * argv[]) { |
---|
24 | unsigned int times = 1; |
---|
25 | unsigned int total_frames = 1; |
---|
26 | if (1 < argc) { |
---|
27 | times = strto(argv[1], 0p, 10); |
---|
28 | } |
---|
29 | if (2 < argc) { |
---|
30 | total_frames = strto(argv[2], 0p, 10); |
---|
31 | } |
---|
32 | |
---|
33 | Time start_time = timeHiRes(); |
---|
34 | for (unsigned int count = 0 ; count < times ; ++count) { |
---|
35 | try { |
---|
36 | nounwind_empty(total_frames); |
---|
37 | } catchResume (fixup_exception * ex) { |
---|
38 | ex->fixup = total_frames + 42; |
---|
39 | } |
---|
40 | } |
---|
41 | Time end_time = timeHiRes(); |
---|
42 | sout | "Run-Time (s): " | wd(0,1, (end_time - start_time)`ns / 1_000_000_000.); |
---|
43 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.