ADT
ast-experimental
enum
forall-pointer-decay
jacob/cs343-translation
new-ast-unique-expr
pthread-emulation
qualifiedEnum
Last change
on this file since b7d94ac5 was ee23a8d, checked in by Andrew Beach <ajbeach@…>, 4 years ago |
Added duration information (in nanoseconds) to EHM benchmarks.
|
-
Property mode
set to
100644
|
File size:
872 bytes
|
Rev | Line | |
---|
[ea593a3] | 1 | // Conditional Match (or Re-Raise)
|
---|
[ee23a8d] | 2 | #include <clock.hfa>
|
---|
[ea593a3] | 3 | #include <exception.hfa>
|
---|
[ee23a8d] | 4 | #include <fstream.hfa>
|
---|
[ea593a3] | 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 | unsigned int total_frames = 1;
|
---|
[ee23a8d] | 28 | if (1 < argc) {
|
---|
[ea593a3] | 29 | times = strtol(argv[1], 0p, 10);
|
---|
| 30 | }
|
---|
[ee23a8d] | 31 | if (2 < argc) {
|
---|
[ea593a3] | 32 | total_frames = strtol(argv[2], 0p, 10);
|
---|
| 33 | }
|
---|
| 34 |
|
---|
[ee23a8d] | 35 | Time start_time = time();
|
---|
[ea593a3] | 36 | for (unsigned int count = 0 ; count < times ; ++count) {
|
---|
| 37 | try {
|
---|
| 38 | cond_catch();
|
---|
| 39 | } catch (empty_exception * exc) {
|
---|
| 40 | // ...
|
---|
| 41 | }
|
---|
| 42 | }
|
---|
[ee23a8d] | 43 | Time end_time = time();
|
---|
| 44 | sout | "Run-Time (ns): " | (end_time - start_time)`ns;
|
---|
[ea593a3] | 45 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.