Changeset c87cd93 for doc/generic_types/evaluation/cpp-bench.cpp
- Timestamp:
- Apr 17, 2017, 3:47:07 PM (7 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:
- 4ae83a4b
- Parents:
- 33e22da
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
doc/generic_types/evaluation/cpp-bench.cpp
r33e22da rc87cd93 1 1 #include <algorithm> 2 2 #include <fstream> 3 #include <utility>4 3 #include "bench.hpp" 5 4 #include "cpp-stack.hpp" 5 #include "cpp-pair.hpp" 6 6 #include "cpp-print.hpp" 7 7 8 8 int main(int argc, char** argv) { 9 9 std::ofstream out{"cpp-out.txt"}; 10 int max = 0;11 stack<int> s , t;10 int maxi = 0, vali = 42; 11 stack<int> si, ti; 12 12 13 REPEAT_TIMED( "push_int", s.push( int{_i} ); ) 14 TIMED( "copy_int", t = s; ) 15 TIMED( "clear_int", s.clear(); ) 16 REPEAT_TIMED( "pop_int", max = std::max( max, t.pop() ); ) 17 print( out, max, "\n" ); 18 REPEAT_N_TIMED( "print_int", N/2, print( out, _i, ":", _i, "\n" ); ) 13 REPEAT_TIMED( "push_int", N, si.push( vali ); ) 14 TIMED( "copy_int", ti = si; ) 15 TIMED( "clear_int", si.clear(); ) 16 REPEAT_TIMED( "pop_int", N, maxi = std::max( maxi, ti.pop() ); ) 17 REPEAT_TIMED( "print_int", N/2, print( out, vali, ":", vali, "\n" ); ) 19 18 20 std::pair<bool, char> max1 = { false, '\0' };21 stack< std::pair<bool, char>> s1, t1;19 pair<bool, char> maxp = { false, '\0' }, valp = { true, 'a' }; 20 stack<pair<bool, char>> sp, tp; 22 21 23 REPEAT_TIMED( "push_bool_char", s1.push( std::pair<bool, char>{ _i & 0x1, _i & 0x7F } ); ) 24 TIMED( "copy_bool_char", t1 = s1; ) 25 TIMED( "clear_bool_char", s1.clear(); ) 26 REPEAT_TIMED( "pop_bool_char", max1 = std::max( max1, t1.pop() ); ) 27 print( out, max1, "\n" ); 28 REPEAT_N_TIMED( "print_pair", N/2, 29 print( out, std::pair<bool, char>{ _i & 0x1, _i & 0x7F }, ":", 30 std::pair<bool, char>{ _i & 0x1, _i & 0x7F }, "\n" ); ) 22 REPEAT_TIMED( "push_pair", N, sp.push( valp ); ) 23 TIMED( "copy_pair", tp = sp; ) 24 TIMED( "clear_pair", sp.clear(); ) 25 REPEAT_TIMED( "pop_pair", N, maxp = std::max( maxp, tp.pop() ); ) 26 REPEAT_TIMED( "print_pair", N/2, print( out, valp, ":", valp, "\n" ); ) 31 27 }
Note: See TracChangeset
for help on using the changeset viewer.