[87c5f40] | 1 | #include <stdlib> |
---|
[0d10090] | 2 | #include <stdio.h> |
---|
[309be81] | 3 | #include "bench.h" |
---|
| 4 | #include "cfa-stack.h" |
---|
[c87cd93] | 5 | #include "cfa-pair.h" |
---|
[0d10090] | 6 | #include "cfa-print.h" |
---|
[309be81] | 7 | |
---|
[79b8dc3] | 8 | int main( int argc, char *argv[] ) { |
---|
| 9 | FILE * out = fopen( "cfa-out.txt", "w" ); |
---|
[c87cd93] | 10 | int maxi = 0, vali = 42; |
---|
| 11 | stack(int) si, ti; |
---|
[a381b46] | 12 | |
---|
[c87cd93] | 13 | REPEAT_TIMED( "push_int", N, push( &si, vali ); ) |
---|
| 14 | TIMED( "copy_int", ti = si; ) |
---|
| 15 | TIMED( "clear_int", clear( &si ); ) |
---|
| 16 | REPEAT_TIMED( "pop_int", N, |
---|
| 17 | int xi = pop( &ti ); |
---|
| 18 | if ( xi > maxi ) { maxi = xi; } ) |
---|
| 19 | REPEAT_TIMED( "print_int", N/2, print( out, vali, ":", vali, "\n" ); ) |
---|
[79b8dc3] | 20 | |
---|
[c87cd93] | 21 | pair(_Bool, char) maxp = { (_Bool)0, '\0' }, valp = { (_Bool)1, 'a' }; |
---|
| 22 | stack(pair(_Bool, char)) sp, tp; |
---|
[a381b46] | 23 | |
---|
[c87cd93] | 24 | REPEAT_TIMED( "push_pair", N, push( &sp, valp ); ) |
---|
| 25 | TIMED( "copy_pair", tp = sp; ) |
---|
| 26 | TIMED( "clear_pair", clear( &sp ); ) |
---|
| 27 | REPEAT_TIMED( "pop_pair", N, |
---|
| 28 | pair(_Bool, char) xp = pop( &tp ); |
---|
| 29 | if ( xp > maxp ) { maxp = xp; } ) |
---|
| 30 | REPEAT_TIMED( "print_pair", N/2, print( out, valp, ":", valp, "\n" ); ) |
---|
[0d10090] | 31 | fclose(out); |
---|
[309be81] | 32 | } |
---|