source: doc/generic_types/evaluation/cpp-bench.cpp @ 79b8dc3

aaron-thesisarm-ehcleanup-dtorsdeferred_resndemanglerjacob/cs343-translationjenkins-sandboxnew-astnew-envno_listpersistent-indexerresolv-newwith_gc
Last change on this file since 79b8dc3 was 79b8dc3, checked in by Aaron Moss <a3moss@…>, 4 years ago

Some compaction of benchmark code

  • Property mode set to 100644
File size: 1009 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        stack<int> s, t;
11        int max = 0;
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() ); )
16        print( out, max, "\n" );
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" );
26        REPEAT_N_TIMED( "print_pair", N/2, 
27                print( out, std::pair<bool, char>{ _i & 0x1, _i & 0x7F }, ":",
28                                std::pair<bool, char>{ _i & 0x1, _i & 0x7F }, "\n" ); )
29}
Note: See TracBrowser for help on using the repository browser.