Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • doc/theses/andrew_beach_MMath/code/resume-empty.cfa

    r54651005 r18783b4  
    33#include <exception.hfa>
    44#include <fstream.hfa>
    5 #include <stdlib.hfa>
     5#include <stdlib.hfa>                                                                   // strto
    66
    7 EHM_EXCEPTION(empty_exception)();
     7exception empty_exception;
     8vtable(empty_exception) empty_vt;
    89
    9 EHM_VIRTUAL_TABLE(empty_exception, empty_vt);
    10 
    11 void unwind_empty(unsigned int frames) {
     10void nounwind_empty(unsigned int frames) {
    1211        if (frames) {
    13                 unwind_empty(frames - 1);
     12                nounwind_empty(frames - 1);
     13                if ( frames == -1 ) printf( "42" );                             // prevent recursion optimizations
    1414        } else {
    1515                throwResume (empty_exception){&empty_vt};
     
    2121        unsigned int total_frames = 1;
    2222        if (1 < argc) {
    23                 times = strtol(argv[1], 0p, 10);
     23                times = strto(argv[1], 0p, 10);
    2424        }
    2525        if (2 < argc) {
    26                 total_frames = strtol(argv[2], 0p, 10);
     26                total_frames = strto(argv[2], 0p, 10);
    2727        }
    2828
    2929        Time start_time = timeHiRes();
    30         for (int count = 0 ; count < times ; ++count) {
     30        for (unsigned int count = 0 ; count < times ; ++count) {
    3131                try {
    32                         unwind_empty(total_frames);
     32                        nounwind_empty(total_frames);
    3333                } catchResume (empty_exception *) {
    3434                        asm volatile ("# fixup block");
     
    3636        }
    3737        Time end_time = timeHiRes();
    38         sout | "Run-Time (ns): " | (end_time - start_time)`ns;
     38        sout | "Run-Time (s): " | wd(0,1, (end_time - start_time)`ns / 1_000_000_000.);
    3939}
Note: See TracChangeset for help on using the changeset viewer.