Changeset 79b8dc3 for doc/generic_types/evaluation/cpp-vbench.cpp
- Timestamp:
- Apr 14, 2017, 6:24:35 PM (6 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- 17f27d40, 1c38f5b, 6eb4398
- Parents:
- 4570131
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
doc/generic_types/evaluation/cpp-vbench.cpp
r4570131 r79b8dc3 1 1 #include <algorithm> 2 2 #include <fstream> 3 #include <stdlib.h>4 3 #include "bench.hpp" 5 4 #include "cpp-vstack.hpp" … … 9 8 int main(int argc, char** argv) { 10 9 std::ofstream out{"cpp-vout.txt"}; 11 srand(20171025); 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"} ); ) 12 19 13 stack s; 14 REPEAT_TIMED( "push_int", 15 s.push( std::make_unique<integer>( rand() ) ); 16 ) 17 18 stack t; 19 TIMED( "copy_int", 20 t = s; 21 ) 22 23 TIMED( "clear_int", 24 s.clear(); 25 ) 26 27 integer max; 28 REPEAT_TIMED( "pop_int", 29 max = std::max( max, t.pop()->as<integer>() ); /***/ 30 ) 31 print( out, max, c_string{"\n"} ); 32 33 REPEAT_N_TIMED( "print_int", N/2, 34 print( out, integer{rand()}, c_string{":"}, integer{rand()}, c_string{"\n"} ); 35 ) 36 37 stack s2; 38 REPEAT_TIMED( "push_bool_char", 39 s2.push( std::make_unique<pair>( std::make_unique<boolean>( rand() & 0x1 ), 40 std::make_unique<character>( rand() & 0x7F ) ) ); 41 ) 42 43 stack t2; 44 TIMED( "copy_bool_char", 45 t2 = s2; 46 ) 47 48 TIMED( "clear_bool_char", 49 s2.clear(); 50 ) 51 52 auto max2 = std::make_unique<pair>( std::make_unique<boolean>(false), 53 std::make_unique<character>('\0') ); 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(); ) 54 26 REPEAT_TIMED( "pop_bool_char", 55 std::unique_ptr<pair> x = as_ptr<pair>( t2.pop() ); /***/ 56 if ( *x > *max2 ) { max2 = std::move(x); } 57 ) 58 print( out, *max2, c_string{"\n"} ); 59 27 ptr<pair> x = as_ptr<pair>( t1.pop() ); /***/ 28 if ( *x > *max1 ) { max1 = std::move(x); } ) 29 print( out, *max1, c_string{"\n"} ); 60 30 REPEAT_N_TIMED( "print_pair", N/2, 61 print( out, pair{ std::make_unique<boolean>( rand() & 0x1 ), 62 std::make_unique<character>( rand() & 0x7F ) }, c_string{":"}, 63 pair{ std::make_unique<boolean>( rand() & 0x1 ), 64 std::make_unique<character>( rand() & 0x7F ) }, c_string{"\n"} ); 65 ) 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"} ); ) 66 33 }
Note: See TracChangeset
for help on using the changeset viewer.