source: doc/theses/andrew_beach_MMath/code/resume-fixup-empty-r.cfa @ eaeca5f

ADTast-experimentalenumforall-pointer-decayjacob/cs343-translationpthread-emulationqualifiedEnum
Last change on this file since eaeca5f was f79ee0d, checked in by Peter A. Buhr <pabuhr@…>, 3 years ago

update exception benchmarks

  • Property mode set to 100644
File size: 949 bytes
Line 
1// Resume Across Empty Function
2#include <clock.hfa>
3#include <exception.hfa>
4#include <fstream.hfa>
5#include <stdlib.hfa>                                                                   // strto
6
7exception fixup_exception {
8        int & fixup;
9};
10vtable(fixup_exception) fixup_vt;
11
12void nounwind_empty(unsigned int frames) {
13        if (frames) {
14                nounwind_empty(frames - 1);
15        } else {
16                int fixup = 17;
17                throwResume (fixup_exception){&fixup_vt, fixup}; // change bad fixup
18        }
19}
20
21int main(int argc, char * argv[]) {
22        unsigned int times = 1;
23        unsigned int total_frames = 1;
24        if (1 < argc) {
25                times = strto(argv[1], 0p, 10);
26        }
27        if (2 < argc) {
28                total_frames = strto(argv[2], 0p, 10);
29        }
30
31        Time start_time = timeHiRes();
32        for (unsigned int count = 0 ; count < times ; ++count) {
33                try {
34                        nounwind_empty(total_frames);
35                } catchResume (fixup_exception * ex) {
36                        ex->fixup = total_frames + 42;
37                }
38        }
39        Time end_time = timeHiRes();
40        sout | "Run-Time (s): " | wd(0,1, (end_time - start_time)`ns / 1_000_000_000.);
41}
Note: See TracBrowser for help on using the repository browser.