[87c5f40] | 1 | #include <algorithm> |
---|
[0d10090] | 2 | #include <fstream> |
---|
[b276be5] | 3 | #include "bench.hpp" |
---|
| 4 | #include "cpp-vstack.hpp" |
---|
[0d10090] | 5 | #include "cpp-vprint.hpp" |
---|
[87c5f40] | 6 | #include "object.hpp" |
---|
[b276be5] | 7 | |
---|
| 8 | int main(int argc, char** argv) { |
---|
[3fb7f5e] | 9 | std::ofstream out{"cpp-vout.txt"}; |
---|
[79b8dc3] | 10 | stack s, t; |
---|
| 11 | integer max{ 0 }; |
---|
| 12 | REPEAT_TIMED( "push_int", s.push( make<integer>( _i ) ); ) |
---|
| 13 | TIMED( "copy_int", t = s; ) |
---|
| 14 | TIMED( "clear_int", s.clear(); ) |
---|
| 15 | REPEAT_TIMED( "pop_int", max = std::max( max, t.pop()->as<integer>() ); /***/ ) |
---|
[3fb7f5e] | 16 | print( out, max, c_string{"\n"} ); |
---|
| 17 | REPEAT_N_TIMED( "print_int", N/2, |
---|
[79b8dc3] | 18 | print( out, integer{_i}, c_string{":"}, integer{_i}, c_string{"\n"} ); ) |
---|
| 19 | |
---|
| 20 | stack s1, t1; |
---|
| 21 | ptr<pair> max1 = make<pair>( make<boolean>(false), make<character>('\0') ); |
---|
| 22 | REPEAT_TIMED( "push_bool_char", |
---|
| 23 | s1.push( make<pair>( make<boolean>(_i & 1), make<character>(_i & 0x7F) ) ); ) |
---|
| 24 | TIMED( "copy_bool_char", t1 = s1; ) |
---|
| 25 | TIMED( "clear_bool_char", s1.clear(); ) |
---|
[87c5f40] | 26 | REPEAT_TIMED( "pop_bool_char", |
---|
[79b8dc3] | 27 | ptr<pair> x = as_ptr<pair>( t1.pop() ); /***/ |
---|
| 28 | if ( *x > *max1 ) { max1 = std::move(x); } ) |
---|
| 29 | print( out, *max1, c_string{"\n"} ); |
---|
[3fb7f5e] | 30 | REPEAT_N_TIMED( "print_pair", N/2, |
---|
[79b8dc3] | 31 | print( out, pair{ make<boolean>(_i & 1), make<character>(_i & 0x7F) }, c_string{":"}, |
---|
| 32 | pair{ make<boolean>(_i & 1), make<character>(_i & 0x7F) }, c_string{"\n"} ); ) |
---|
[b276be5] | 33 | } |
---|