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

ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsdeferred_resndemanglerenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumresolv-newwith_gc
Last change on this file since d9dd3d1 was 0d10090, checked in by Aaron Moss <a3moss@…>, 7 years ago

Add printing code to benchmark

  • Property mode set to 100644
File size: 1.1 KB
Line 
1#include <stdlib>
2#include <stdlib.h>
3#include <stdio.h>
4#include "pair"
5#include "bench.h"
6#include "cfa-stack.h"
7#include "cfa-print.h"
8
9int main(int argc, char** argv) {
10        srand(20171025);
11
12        stack(int) s;
13        REPEAT_TIMED( "push_int",
14                push( &s, rand() );
15        )
16
17        stack(int) t;
18        TIMED( "copy_int", 
19                t = s;
20        )
21
22        TIMED( "clear_int", 
23                clear( &s );
24        )
25
26        int max = 0;
27        REPEAT_TIMED( "pop_int", 
28                max = max( max, pop( &t ) );
29        )
30
31        stack(pair(_Bool, char)) s2;
32        REPEAT_TIMED( "push_bool_char",
33                push( &s2, (pair(_Bool, char)){ rand() & 0x1, rand() & 0x7F } );
34        )
35
36        stack(pair(_Bool, char)) t2;
37        TIMED( "copy_bool_char", 
38                t2 = s2;
39        )
40
41        TIMED( "clear_bool_char", 
42                clear( &s2 );
43        )
44
45        pair(_Bool, char) max2 = { (_Bool)0, '\0' };
46        REPEAT_TIMED( "pop_bool_char",
47                max2 = max( max2, pop( &t2 ) );
48        )
49
50        FILE* out = fopen("cfa-out.txt", "w");
51        REPEAT_TIMED( "print_int",
52                print( out, rand(), ":", rand(), "\n" );
53        )
54
55        REPEAT_TIMED( "print_pair",
56                print( out, (pair(_Bool, char)){ rand() & 0x1, rand() & 0x7F }, ":",
57                                (pair(_Bool, char)){ rand() & 0x1, rand() & 0x7F }, "\n" );
58        )
59        fclose(out);
60}
Note: See TracBrowser for help on using the repository browser.