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
RevLine 
[87c5f40]1#include <stdlib>
[309be81]2#include <stdlib.h>
[0d10090]3#include <stdio.h>
[87c5f40]4#include "pair"
[309be81]5#include "bench.h"
6#include "cfa-stack.h"
[0d10090]7#include "cfa-print.h"
[309be81]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        )
[122aecd]16
17        stack(int) t;
18        TIMED( "copy_int", 
19                t = s;
20        )
21
22        TIMED( "clear_int", 
23                clear( &s );
24        )
25
[87c5f40]26        int max = 0;
[122aecd]27        REPEAT_TIMED( "pop_int", 
[87c5f40]28                max = max( max, pop( &t ) );
29        )
30
[ff178ee]31        stack(pair(_Bool, char)) s2;
[87c5f40]32        REPEAT_TIMED( "push_bool_char",
[ff178ee]33                push( &s2, (pair(_Bool, char)){ rand() & 0x1, rand() & 0x7F } );
[87c5f40]34        )
35
[ff178ee]36        stack(pair(_Bool, char)) t2;
[87c5f40]37        TIMED( "copy_bool_char", 
38                t2 = s2;
39        )
40
41        TIMED( "clear_bool_char", 
42                clear( &s2 );
43        )
44
[ff178ee]45        pair(_Bool, char) max2 = { (_Bool)0, '\0' };
[87c5f40]46        REPEAT_TIMED( "pop_bool_char",
47                max2 = max( max2, pop( &t2 ) );
[122aecd]48        )
[0d10090]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);
[309be81]60}
Note: See TracBrowser for help on using the repository browser.