#include #include #include #include "bench.hpp" #include "cpp-vstack.hpp" #include "cpp-vprint.hpp" #include "object.hpp" int main(int argc, char** argv) { std::ofstream out{"cpp-vout.txt"}; srand(20171025); stack s; REPEAT_TIMED( "push_int", s.push( std::make_unique( rand() ) ); ) stack t; TIMED( "copy_int", t = s; ) TIMED( "clear_int", s.clear(); ) integer max; REPEAT_TIMED( "pop_int", max = std::max( max, t.pop()->as() ); /***/ ) print( out, max, c_string{"\n"} ); REPEAT_N_TIMED( "print_int", N/2, print( out, integer{rand()}, c_string{":"}, integer{rand()}, c_string{"\n"} ); ) stack s2; REPEAT_TIMED( "push_bool_char", s2.push( std::make_unique( std::make_unique( rand() & 0x1 ), std::make_unique( rand() & 0x7F ) ) ); ) stack t2; TIMED( "copy_bool_char", t2 = s2; ) TIMED( "clear_bool_char", s2.clear(); ) auto max2 = std::make_unique( std::make_unique(false), std::make_unique('\0') ); REPEAT_TIMED( "pop_bool_char", std::unique_ptr x = as_ptr( t2.pop() ); /***/ if ( *x > *max2 ) { max2 = std::move(x); } ) print( out, *max2, c_string{"\n"} ); REPEAT_N_TIMED( "print_pair", N/2, print( out, pair{ std::make_unique( rand() & 0x1 ), std::make_unique( rand() & 0x7F ) }, c_string{":"}, pair{ std::make_unique( rand() & 0x1 ), std::make_unique( rand() & 0x7F ) }, c_string{"\n"} ); ) }