Last change
on this file since 5ca5263 was
f79ee0d,
checked in by Peter A. Buhr <pabuhr@…>, 3 years ago
|
update exception benchmarks
|
-
Property mode set to
100644
|
File size:
750 bytes
|
Line | |
---|
1 | // Cross a Try Statement With Finally Clause |
---|
2 | #include <clock.hfa> |
---|
3 | #include <exception.hfa> |
---|
4 | #include <fstream.hfa> |
---|
5 | #include <stdlib.hfa> // strto |
---|
6 | |
---|
7 | exception not_raised_exception; |
---|
8 | vtable(not_raised_exception) not_vt; |
---|
9 | |
---|
10 | int main(int argc, char * argv[]) { |
---|
11 | unsigned int times = 1; |
---|
12 | volatile bool should_throw = false; |
---|
13 | if (1 < argc) { |
---|
14 | times = strto(argv[1], 0p, 10); |
---|
15 | } |
---|
16 | |
---|
17 | Time start_time = timeHiRes(); |
---|
18 | for (unsigned int count = 0 ; count < times ; ++count) { |
---|
19 | try { |
---|
20 | asm volatile ("# try block"); |
---|
21 | if (should_throw) { |
---|
22 | throw (not_raised_exception){¬_vt}; |
---|
23 | } |
---|
24 | } finally { |
---|
25 | asm volatile ("# finally block"); |
---|
26 | } |
---|
27 | } |
---|
28 | Time end_time = timeHiRes(); |
---|
29 | sout | "Run-Time (s): " | wd(0,1, (end_time - start_time)`ns / 1_000_000_000.); |
---|
30 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.