ADTast-experimentalenumforall-pointer-decayjacob/cs343-translationnew-ast-unique-exprpthread-emulationqualifiedEnum
Last change
on this file since 47e413b was
47e413b,
checked in by Andrew Beach <ajbeach@…>, 3 years ago
|
Cforall exception benchmarks now use a more high resolution clock.
|
-
Property mode set to
100644
|
File size:
850 bytes
|
Line | |
---|
1 | // Conditional Match (or Re-Raise) |
---|
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 | bool should_catch = false; |
---|
12 | |
---|
13 | void throw_exception() { |
---|
14 | throw (empty_exception){&empty_vt}; |
---|
15 | } |
---|
16 | |
---|
17 | void cond_catch() { |
---|
18 | try { |
---|
19 | throw_exception(); |
---|
20 | } catch (empty_exception * exc ; should_catch) { |
---|
21 | // ... |
---|
22 | } |
---|
23 | } |
---|
24 | |
---|
25 | int main(int argc, char * argv[]) { |
---|
26 | unsigned int times = 1; |
---|
27 | if (1 < argc) { |
---|
28 | times = strtol(argv[1], 0p, 10); |
---|
29 | } |
---|
30 | if (2 < argc) { |
---|
31 | should_catch = strtol(argv[2], 0p, 10); |
---|
32 | } |
---|
33 | |
---|
34 | Time start_time = timeHiRes(); |
---|
35 | for (unsigned int count = 0 ; count < times ; ++count) { |
---|
36 | try { |
---|
37 | cond_catch(); |
---|
38 | } catch (empty_exception * exc) { |
---|
39 | // ... |
---|
40 | } |
---|
41 | } |
---|
42 | Time end_time = timeHiRes(); |
---|
43 | sout | "Run-Time (ns): " | (end_time - start_time)`ns; |
---|
44 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.