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

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 a381b46 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
Line 
1#include <algorithm>
2#include <fstream>
3#include <utility>
4#include "bench.hpp"
5#include "cpp-stack.hpp"
6#include "cpp-print.hpp"
7
8int main(int argc, char** argv) {
9        std::ofstream out{"cpp-out.txt"};
10        int max = 0;
11        stack<int> s, t;
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" ); )
19
20        std::pair<bool, char> max1 = { false, '\0' };
21        stack<std::pair<bool, char>> s1, t1;
22       
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" ); )
31}
Note: See TracBrowser for help on using the repository browser.