source: doc/generic_types/evaluation/cfa-bench.c @ a381b46

aaron-thesisarm-ehcleanup-dtorsdeferred_resndemanglerjacob/cs343-translationjenkins-sandboxnew-astnew-envno_listpersistent-indexerresolv-newwith_gc
Last change on this file since a381b46 was a381b46, checked in by Aaron Moss <a3moss@…>, 4 years ago

Minor cleanup, also filled in benchmark source appendix

  • Property mode set to 100644
File size: 976 bytes
Line 
1#include <stdlib>
2#include <stdio.h>
3#include "pair"
4#include "bench.h"
5#include "cfa-stack.h"
6#include "cfa-print.h"
7
8int main( int argc, char *argv[] ) {
9        FILE * out = fopen( "cfa-out.txt", "w" );
10        int max = 0;
11        stack(int) s, t;
12
13        REPEAT_TIMED( "push_int", push( &s, _i ); )
14        TIMED( "copy_int", t = s; )
15        TIMED( "clear_int", clear( &s ); )
16        REPEAT_TIMED( "pop_int", 
17                int x = pop(&t); 
18                if ( x > max ) { max = x; } )
19        REPEAT_TIMED( "print_int", print( out, _i, ":", _i, "\n" ); )
20
21        stack(pair(_Bool, char)) s1, t1;
22        pair(_Bool, char) max = { (_Bool)0, '\0' };
23
24        REPEAT_TIMED( "push_pair", push( &s1, (pair(_Bool, char)){ _i & 1, _i &0x7F } ); )
25        TIMED( "copy_pair", t1 = s1; )
26        TIMED( "clear_pair", clear( &s1 ); )
27        REPEAT_TIMED( "pop_pair",
28                pair(_Bool, char) x = pop(&t1); 
29                if ( x > max ) { max = x; } )
30        REPEAT_TIMED( "print_pair",
31                 print( out, (pair(_Bool, char)){  _i & 1, _i &0x7F }, ":", 
32                        (pair(_Bool, char)){  _i & 1, _i &0x7F }, "\n" ); )
33        fclose(out);
34}
Note: See TracBrowser for help on using the repository browser.