ADTast-experimentalenumforall-pointer-decayjacob/cs343-translationnew-ast-unique-exprpthread-emulationqualifiedEnum
Last change
on this file since 11ad42f was
ee23a8d,
checked in by Andrew Beach <ajbeach@…>, 3 years ago
|
Added duration information (in nanoseconds) to EHM benchmarks.
|
-
Property mode set to
100644
|
File size:
847 bytes
|
Line | |
---|
1 | // Throw Across Finally |
---|
2 | #include <clock.hfa> |
---|
3 | #include <exception.hfa> |
---|
4 | #include <fstream.hfa> |
---|
5 | #include <stdlib.hfa> |
---|
6 | |
---|
7 | EHM_EXCEPTION(empty_exception)(); |
---|
8 | |
---|
9 | EHM_VIRTUAL_TABLE(empty_exception, empty_vt); |
---|
10 | |
---|
11 | void unwind_finally(unsigned int frames) { |
---|
12 | if (frames) { |
---|
13 | try { |
---|
14 | unwind_finally(frames - 1); |
---|
15 | } finally { |
---|
16 | // ... |
---|
17 | } |
---|
18 | } else { |
---|
19 | throw (empty_exception){&empty_vt}; |
---|
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 = strtol(argv[1], 0p, 10); |
---|
28 | } |
---|
29 | if (2 < argc) { |
---|
30 | total_frames = strtol(argv[2], 0p, 10); |
---|
31 | } |
---|
32 | |
---|
33 | Time start_time = timeHiRes(); |
---|
34 | for (int count = 0 ; count < times ; ++count) { |
---|
35 | try { |
---|
36 | unwind_finally(total_frames); |
---|
37 | } catch (empty_exception *) { |
---|
38 | // ... |
---|
39 | } |
---|
40 | } |
---|
41 | Time end_time = timeHiRes(); |
---|
42 | sout | "Run-Time (ns): " | (end_time - start_time)`ns; |
---|
43 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.