source: doc/theses/andrew_beach_MMath/code/cond-fixup.cfa @ 830edc6

Last change on this file since 830edc6 was f79ee0d, checked in by Peter A. Buhr <pabuhr@…>, 3 years ago

update exception benchmarks

  • Property mode set to 100644
File size: 886 bytes
Line 
1// Conditional Match (or Re-Raise)
2#include <clock.hfa>
3#include <exception.hfa>
4#include <fstream.hfa>
5#include <stdlib.hfa>                                                                   // strto
6
7exception empty_exception;
8vtable(empty_exception) empty_vt;
9
10bool should_catch = false;
11
12int main(int argc, char * argv[]) {
13        unsigned int times = 1;
14        if (1 < argc) {
15                times = strto(argv[1], 0p, 10);
16        }
17        if (2 < argc) {
18                should_catch = (unsigned int)strto(argv[2], 0p, 2);
19        }
20
21        Time start_time = timeHiRes();
22        for (unsigned int count = 0 ; count < times ; ++count) {
23                try {
24                        throwResume (empty_exception){&empty_vt};
25                } catchResume (empty_exception * exc ; should_catch) {
26                        asm volatile ("# fixup block (conditional)");
27                } catchResume (empty_exception * exc) {
28                        asm volatile ("# fixup block (unconditional)");
29                }
30        }
31        Time end_time = timeHiRes();
32        sout | "Run-Time (s): " | wd(0,1, (end_time - start_time)`ns / 1_000_000_000.);
33}
Note: See TracBrowser for help on using the repository browser.