source: doc/theses/andrew_beach_MMath/code/try-resume.cfa @ e15293b

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

update exception benchmarks

  • Property mode set to 100644
File size: 701 bytes
RevLine 
[ea593a3]1// Cross a Try Statement With Finally Clause
[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;
[ea593a3]8
9int main(int argc, char * argv[]) {
10        unsigned int times = 1;
11        unsigned int total_frames = 1;
[ee23a8d]12        if (1 < argc) {
[f79ee0d]13                times = strto(argv[1], 0p, 10);
[ea593a3]14        }
[ee23a8d]15        if (2 < argc) {
[f79ee0d]16                total_frames = strto(argv[2], 0p, 10);
[ea593a3]17        }
18
[47e413b]19        Time start_time = timeHiRes();
[ea593a3]20        for (unsigned int count = 0 ; count < times ; ++count) {
21                try {
[54651005]22                        asm volatile ("");
[ea593a3]23                } catchResume (not_raised_exception *) {
[54651005]24                        asm volatile ("");
[ea593a3]25                }
26        }
[47e413b]27        Time end_time = timeHiRes();
[f79ee0d]28        sout | "Run-Time (s): " | wd(0,1, (end_time - start_time)`ns / 1_000_000_000.);
[ea593a3]29}
Note: See TracBrowser for help on using the repository browser.