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