Ignore:
Timestamp:
Apr 17, 2017, 3:47:07 PM (7 years ago)
Author:
Aaron Moss <a3moss@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
4ae83a4b
Parents:
33e22da
Message:

Final version of the benchmark code

File:
1 edited

Legend:

Unmodified
Added
Removed
  • doc/generic_types/evaluation/cpp-vbench.cpp

    r33e22da rc87cd93  
    88int main(int argc, char** argv) {
    99        std::ofstream out{"cpp-vout.txt"};
    10         integer max{ 0 };
    11         stack s, t;
     10        integer maxi{ 0 }, vali{ 42 };
     11        stack si, ti;
    1212       
    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"} ); )
     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"} ); )
    2018
    21         ptr<pair> max1 = make<pair>( make<boolean>(false), make<character>('\0') );
    22         stack s1, t1;
     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;
    2322       
    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"} ); )
     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"} ); )
    3530}
Note: See TracChangeset for help on using the changeset viewer.