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

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

Final version of the benchmark code

  • Property mode set to 100644
File size: 1.0 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 maxi{ 0 }, vali{ 42 };
11        stack si, ti;
12       
13        REPEAT_TIMED( "push_int", N, si.push( vali ); )
14        TIMED( "copy_int", ti = si; )
15        TIMED( "clear_int", si.clear(); )
16        REPEAT_TIMED( "pop_int", N, maxi = std::max( maxi, ti.pop()->as<integer>() ); /***/ )
17        REPEAT_TIMED( "print_int", N/2, print( out, vali, c_string{":"}, vali, c_string{"\n"} ); )
18
19        ptr<pair> maxp = make<pair>( make<boolean>(false), make<character>('\0') );
20        pair valp{ make<boolean>(true), make<character>('a') };
21        stack sp, tp;
22       
23        REPEAT_TIMED( "push_pair", N, sp.push( valp ); )
24        TIMED( "copy_pair", tp = sp; )
25        TIMED( "clear_pair", sp.clear(); )
26        REPEAT_TIMED( "pop_pair", N, 
27                ptr<pair> xp = as_ptr<pair>( tp.pop() ); /***/
28                if ( *xp > *maxp ) { maxp = std::move(xp); } )
29        REPEAT_TIMED( "print_pair", N/2, print( out, valp, c_string{":"}, valp, c_string{"\n"} ); )
30}
Note: See TracBrowser for help on using the repository browser.