1 | #include <algorithm> |
---|
2 | #include <fstream> |
---|
3 | #include "bench.hpp" |
---|
4 | #include "cpp-vstack.hpp" |
---|
5 | #include "cpp-vprint.hpp" |
---|
6 | #include "object.hpp" |
---|
7 | |
---|
8 | int main(int argc, char** argv) { |
---|
9 | std::ofstream out{"cpp-vout.txt"}; |
---|
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>() ); /***/ ) |
---|
16 | print( out, max, c_string{"\n"} ); |
---|
17 | REPEAT_N_TIMED( "print_int", N/2, |
---|
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(); ) |
---|
26 | REPEAT_TIMED( "pop_bool_char", |
---|
27 | ptr<pair> x = as_ptr<pair>( t1.pop() ); /***/ |
---|
28 | if ( *x > *max1 ) { max1 = std::move(x); } ) |
---|
29 | print( out, *max1, c_string{"\n"} ); |
---|
30 | REPEAT_N_TIMED( "print_pair", N/2, |
---|
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"} ); ) |
---|
33 | } |
---|