source: doc/theses/andrew_beach_MMath/code/resume-other.cfa @ 5a4b403

ADTast-experimental
Last change on this file since 5a4b403 was f79ee0d, checked in by Peter A. Buhr <pabuhr@…>, 3 years ago

update exception benchmarks

  • Property mode set to 100644
File size: 1012 bytes
Line 
1// Resume Across Other Handler
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;
9exception not_raised_exception;
10
11void nounwind_other(unsigned int frames) {
12        if (frames) {
13                try {
14                        nounwind_other(frames - 1);
15                } catchResume (not_raised_exception *) {
16                        asm volatile ("# fixup block (stack)");
17                }
18        } else {
19                throwResume (empty_exception){&empty_vt};
20        }
21}
22
23int main(int argc, char * argv[]) {
24        unsigned int times = 1;
25        unsigned int total_frames = 1;
26        if (1 < argc) {
27                times = strto(argv[1], 0p, 10);
28        }
29        if (2 < argc) {
30                total_frames = strto(argv[2], 0p, 10);
31        }
32
33        Time start_time = timeHiRes();
34        for (int count = 0 ; count < times ; ++count) {
35                try {
36                        nounwind_other(total_frames);
37                } catchResume (empty_exception *) {
38                        asm volatile ("# fixup block (base)");
39                }
40        }
41        Time end_time = timeHiRes();
42        sout | "Run-Time (s): " | wd(0,1, (end_time - start_time)`ns / 1_000_000_000.);
43}
Note: See TracBrowser for help on using the repository browser.