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

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

Minor cleanup, also filled in benchmark source appendix

  • Property mode set to 100644
File size: 1.2 KB
Line 
1#include <algorithm>
2#include <fstream>
3#include "bench.hpp"
4#include "cpp-vstack.hpp"
5#include "cpp-vprint.hpp"
6#include "object.hpp"
7
8int main(int argc, char** argv) {
9        std::ofstream out{"cpp-vout.txt"};
10        integer max{ 0 };
11        stack s, t;
12       
13        REPEAT_TIMED( "push_int", s.push( make<integer>( _i ) ); )
14        TIMED( "copy_int", t = s; )
15        TIMED( "clear_int", s.clear(); )
16        REPEAT_TIMED( "pop_int", max = std::max( max, t.pop()->as<integer>() ); /***/ )
17        print( out, max, c_string{"\n"} );
18        REPEAT_N_TIMED( "print_int", N/2, 
19                print( out, integer{_i}, c_string{":"}, integer{_i}, c_string{"\n"} ); )
20
21        ptr<pair> max1 = make<pair>( make<boolean>(false), make<character>('\0') );
22        stack s1, t1;
23       
24        REPEAT_TIMED( "push_bool_char", 
25                s1.push( make<pair>( make<boolean>(_i & 1), make<character>(_i & 0x7F) ) ); )
26        TIMED( "copy_bool_char", t1 = s1; )
27        TIMED( "clear_bool_char", s1.clear(); )
28        REPEAT_TIMED( "pop_bool_char",
29                ptr<pair> x = as_ptr<pair>( t1.pop() ); /***/
30                if ( *x > *max1 ) { max1 = std::move(x); } )
31        print( out, *max1, c_string{"\n"} );
32        REPEAT_N_TIMED( "print_pair", N/2, 
33                print( out, pair{ make<boolean>(_i & 1), make<character>(_i & 0x7F) }, c_string{":"}, 
34                        pair{ make<boolean>(_i & 1), make<character>(_i & 0x7F) }, c_string{"\n"} ); )
35}
Note: See TracBrowser for help on using the repository browser.