source: doc/theses/andrew_beach_MMath/code/cond-fixup.cfa @ 7a15b7e

ADTast-experimentalenumforall-pointer-decaypthread-emulationqualifiedEnum
Last change on this file since 7a15b7e was f79ee0d, checked in by Peter A. Buhr <pabuhr@…>, 3 years ago

update exception benchmarks

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