| Last change
 on this file since 597f284 was             812ba3d, checked in by Andrew Beach <ajbeach@…>, 4 years ago | 
        
          | 
Some clean-up to make Peter's changes to the exception benchmarks fit in better. And make test.sh a bit more robust.
 | 
        
          | 
              
Property                 mode
 set to                 100644 | 
        
          | File size:
            981 bytes | 
      
      
| Rev | Line |  | 
|---|
| [f79ee0d] | 1 | // Resume Across Fixup | 
|---|
|  | 2 | #include <clock.hfa> | 
|---|
|  | 3 | #include <fstream.hfa> | 
|---|
| [812ba3d] | 4 | #include <stdlib.hfa> | 
|---|
| [f79ee0d] | 5 |  | 
|---|
| [18783b4] | 6 | void nounwind_fixup(unsigned int frames, void (*raised_rtn)(int &)) { | 
|---|
| [f79ee0d] | 7 | if (frames) { | 
|---|
| [18783b4] | 8 | nounwind_fixup(frames - 1, raised_rtn); | 
|---|
| [812ba3d] | 9 | // "Always" false, but prevents recursion elimination. | 
|---|
|  | 10 | if (-1 == frames) printf("~"); | 
|---|
| [f79ee0d] | 11 | } else { | 
|---|
|  | 12 | int fixup = 17; | 
|---|
|  | 13 | raised_rtn(fixup); | 
|---|
|  | 14 | } | 
|---|
|  | 15 | } | 
|---|
|  | 16 |  | 
|---|
|  | 17 | int main(int argc, char * argv[]) { | 
|---|
|  | 18 | unsigned int times = 1; | 
|---|
|  | 19 | unsigned int total_frames = 1; | 
|---|
|  | 20 | if (1 < argc) { | 
|---|
|  | 21 | times = strto(argv[1], 0p, 10); | 
|---|
|  | 22 | } | 
|---|
|  | 23 | if (2 < argc) { | 
|---|
|  | 24 | total_frames = strto(argv[2], 0p, 10); | 
|---|
|  | 25 | } | 
|---|
|  | 26 |  | 
|---|
| [812ba3d] | 27 | // Closures at the top level are allowed to be true closures. | 
|---|
| [f79ee0d] | 28 | void raised(int & fixup) { | 
|---|
| [812ba3d] | 29 | fixup = total_frames + 42; | 
|---|
|  | 30 | if (total_frames == 42) printf("42"); | 
|---|
| [f79ee0d] | 31 | } | 
|---|
|  | 32 |  | 
|---|
|  | 33 | Time start_time = timeHiRes(); | 
|---|
|  | 34 | for (unsigned int count = 0 ; count < times ; ++count) { | 
|---|
|  | 35 | nounwind_fixup(total_frames, raised); | 
|---|
|  | 36 | } | 
|---|
|  | 37 | Time end_time = timeHiRes(); | 
|---|
|  | 38 | sout | "Run-Time (s): " | wd(0,1, (end_time - start_time)`ns / 1_000_000_000.); | 
|---|
|  | 39 | } | 
|---|
       
      
  Note:
 See   
TracBrowser
 for help on using the repository browser.