Last change
on this file since 562ccf9 was
f79ee0d,
checked in by Peter A. Buhr <pabuhr@…>, 3 years ago
|
update exception benchmarks
|
-
Property mode set to
100644
|
File size:
1.1 KB
|
Line | |
---|
1 | // Throw Across Other Handler |
---|
2 | #include <clock.hfa> |
---|
3 | #include <exception.hfa> |
---|
4 | #include <fstream.hfa> |
---|
5 | #include <stdlib.hfa> // strto |
---|
6 | |
---|
7 | exception empty_exception; |
---|
8 | vtable(empty_exception) empty_vt; |
---|
9 | exception not_raised_exception; |
---|
10 | |
---|
11 | unsigned int frames; // use global because of gcc thunk problem |
---|
12 | |
---|
13 | void unwind_other(unsigned int dummy) { |
---|
14 | if (frames) { |
---|
15 | frames -= 1; |
---|
16 | try { |
---|
17 | unwind_other(42); |
---|
18 | } catch (not_raised_exception *) { |
---|
19 | asm volatile ("# catch block (stack)"); |
---|
20 | } |
---|
21 | } else { |
---|
22 | dummy = 42; |
---|
23 | throw (empty_exception){&empty_vt}; |
---|
24 | } |
---|
25 | } |
---|
26 | |
---|
27 | int main(int argc, char * argv[]) { |
---|
28 | unsigned int times = 1; |
---|
29 | unsigned int total_frames = 1; |
---|
30 | if (1 < argc) { |
---|
31 | times = strto(argv[1], 0p, 10); |
---|
32 | } |
---|
33 | if (2 < argc) { |
---|
34 | total_frames = strto(argv[2], 0p, 10); |
---|
35 | } |
---|
36 | frames = total_frames; |
---|
37 | |
---|
38 | Time start_time = timeHiRes(); |
---|
39 | for (int count = 0 ; count < times ; ++count) { |
---|
40 | try { |
---|
41 | unwind_other(42); |
---|
42 | } catch (empty_exception *) { |
---|
43 | asm volatile ("# catch block (base)"); |
---|
44 | } |
---|
45 | } |
---|
46 | Time end_time = timeHiRes(); |
---|
47 | sout | "Run-Time (s): " | wd(0,1, (end_time - start_time)`ns / 1_000_000_000.); |
---|
48 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.