ADTast-experimentalenumforall-pointer-decayjacob/cs343-translationnew-ast-unique-exprpthread-emulationqualifiedEnum
Last change
on this file since 9698690 was
54651005,
checked in by Andrew Beach <ajbeach@…>, 3 years ago
|
Added asm statements to the exception benchmarks to prevent unwanted optimizations.
|
-
Property mode set to
100644
|
File size:
845 bytes
|
Line | |
---|
1 | // Throw Across Empty Function |
---|
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_empty(unsigned int frames) { |
---|
12 | if (frames) { |
---|
13 | unwind_empty(frames - 1); |
---|
14 | } else { |
---|
15 | throw (empty_exception){&empty_vt}; |
---|
16 | } |
---|
17 | } |
---|
18 | |
---|
19 | int main(int argc, char * argv[]) { |
---|
20 | unsigned int times = 1; |
---|
21 | unsigned int total_frames = 1; |
---|
22 | if (1 < argc) { |
---|
23 | times = strtol(argv[1], 0p, 10); |
---|
24 | } |
---|
25 | if (2 < argc) { |
---|
26 | total_frames = strtol(argv[2], 0p, 10); |
---|
27 | } |
---|
28 | |
---|
29 | Time start_time = timeHiRes(); |
---|
30 | for (unsigned int count = 0 ; count < times ; ++count) { |
---|
31 | try { |
---|
32 | unwind_empty(total_frames); |
---|
33 | } catch (empty_exception *) { |
---|
34 | asm volatile ("# catch block"); |
---|
35 | } |
---|
36 | } |
---|
37 | Time end_time = timeHiRes(); |
---|
38 | sout | "Run-Time (ns): " | (end_time - start_time)`ns; |
---|
39 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.