| 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 |
|
|---|
| 9 | int main(int argc, char** argv) {
|
|---|
| 10 | FILE* out = fopen("cfa-out.txt", "w");
|
|---|
| 11 | srand(20171025);
|
|---|
| 12 |
|
|---|
| 13 | stack(int) s;
|
|---|
| 14 | REPEAT_TIMED( "push_int",
|
|---|
| 15 | push( &s, rand() );
|
|---|
| 16 | )
|
|---|
| 17 |
|
|---|
| 18 | stack(int) t;
|
|---|
| 19 | TIMED( "copy_int",
|
|---|
| 20 | t = s;
|
|---|
| 21 | )
|
|---|
| 22 |
|
|---|
| 23 | TIMED( "clear_int",
|
|---|
| 24 | clear( &s );
|
|---|
| 25 | )
|
|---|
| 26 |
|
|---|
| 27 | int max = 0;
|
|---|
| 28 | REPEAT_TIMED( "pop_int",
|
|---|
| 29 | max = max( max, pop( &t ) );
|
|---|
| 30 | )
|
|---|
| 31 | print( out, max, "\n" );
|
|---|
| 32 |
|
|---|
| 33 | REPEAT_N_TIMED( "print_int", N/2,
|
|---|
| 34 | print( out, rand(), ":", rand(), "\n" );
|
|---|
| 35 | )
|
|---|
| 36 |
|
|---|
| 37 | stack(pair(_Bool, char)) s2;
|
|---|
| 38 | REPEAT_TIMED( "push_bool_char",
|
|---|
| 39 | push( &s2, (pair(_Bool, char)){ rand() & 0x1, rand() & 0x7F } );
|
|---|
| 40 | )
|
|---|
| 41 |
|
|---|
| 42 | stack(pair(_Bool, char)) t2;
|
|---|
| 43 | TIMED( "copy_bool_char",
|
|---|
| 44 | t2 = s2;
|
|---|
| 45 | )
|
|---|
| 46 |
|
|---|
| 47 | TIMED( "clear_bool_char",
|
|---|
| 48 | clear( &s2 );
|
|---|
| 49 | )
|
|---|
| 50 |
|
|---|
| 51 | pair(_Bool, char) max2 = { (_Bool)0, '\0' };
|
|---|
| 52 | REPEAT_TIMED( "pop_bool_char",
|
|---|
| 53 | max2 = max( max2, pop( &t2 ) );
|
|---|
| 54 | )
|
|---|
| 55 | print( out, max2, "\n" );
|
|---|
| 56 |
|
|---|
| 57 | REPEAT_N_TIMED( "print_pair", N/2,
|
|---|
| 58 | print( out, (pair(_Bool, char)){ rand() & 0x1, rand() & 0x7F }, ":",
|
|---|
| 59 | (pair(_Bool, char)){ rand() & 0x1, rand() & 0x7F }, "\n" );
|
|---|
| 60 | )
|
|---|
| 61 | fclose(out);
|
|---|
| 62 | }
|
|---|