source: doc/theses/andrew_beach_MMath/code/try-catch.cfa @ 01f78e0

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

update exception benchmarks

  • Property mode set to 100644
File size: 778 bytes
RevLine 
[ea593a3]1// Cross a Try Statement with a Termination Handler
[ee23a8d]2#include <clock.hfa>
[ea593a3]3#include <exception.hfa>
[ee23a8d]4#include <fstream.hfa>
[f79ee0d]5#include <stdlib.hfa>                                                                   // strto
[ea593a3]6
[f79ee0d]7exception not_raised_exception;
8vtable(not_raised_exception) not_vt;
[54651005]9
[ea593a3]10int main(int argc, char * argv[]) {
11        unsigned int times = 1;
[866cad3]12        volatile bool should_throw = false;
[ee23a8d]13        if (1 < argc) {
[f79ee0d]14                times = strto(argv[1], 0p, 10);
[ea593a3]15        }
16
[47e413b]17        Time start_time = timeHiRes();
[ea593a3]18        for (unsigned int count = 0 ; count < times ; ++count) {
19                try {
[866cad3]20                        asm volatile ("# try block");
[54651005]21                        if (should_throw) {
22                                throw (not_raised_exception){&not_vt};
23                        }
[ea593a3]24                } catch (not_raised_exception *) {
[54651005]25                        asm volatile ("# catch block");
[ea593a3]26                }
27        }
[47e413b]28        Time end_time = timeHiRes();
[f79ee0d]29        sout | "Run-Time (s): " | wd(0,1, (end_time - start_time)`ns / 1_000_000_000.);
[ea593a3]30}
Note: See TracBrowser for help on using the repository browser.