source: doc/generic_types/evaluation/cpp-bench.cpp @ c57d1935

ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsdeferred_resndemanglerenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumresolv-newwith_gc
Last change on this file since c57d1935 was a381b46, checked in by Aaron Moss <a3moss@…>, 7 years ago

Minor cleanup, also filled in benchmark source appendix

  • Property mode set to 100644
File size: 1018 bytes
RevLine 
[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
8int main(int argc, char** argv) {
[3fb7f5e]9        std::ofstream out{"cpp-out.txt"};
[87c5f40]10        int max = 0;
[a381b46]11        stack<int> s, t;
12       
13        REPEAT_TIMED( "push_int", s.push( int{_i} ); )
[79b8dc3]14        TIMED( "copy_int", t = s; )
15        TIMED( "clear_int", s.clear(); )
16        REPEAT_TIMED( "pop_int", max = std::max( max, t.pop() ); )
[3fb7f5e]17        print( out, max, "\n" );
[79b8dc3]18        REPEAT_N_TIMED( "print_int", N/2, print( out, _i, ":", _i, "\n" ); )
19
20        std::pair<bool, char> max1 = { false, '\0' };
[a381b46]21        stack<std::pair<bool, char>> s1, t1;
22       
[79b8dc3]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" );
[3fb7f5e]28        REPEAT_N_TIMED( "print_pair", N/2, 
[79b8dc3]29                print( out, std::pair<bool, char>{ _i & 0x1, _i & 0x7F }, ":",
30                                std::pair<bool, char>{ _i & 0x1, _i & 0x7F }, "\n" ); )
[309be81]31}
Note: See TracBrowser for help on using the repository browser.