Ignore:
Timestamp:
Apr 19, 2017, 10:15:45 AM (5 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
aaron-thesis, arm-eh, cleanup-dtors, deferred_resn, demangler, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, resolv-new, with_gc
Children:
cd348e7
Parents:
221c2de (diff), de4ce0e (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' of plg.uwaterloo.ca:software/cfa/cfa-cc

File:
1 edited

Legend:

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

    r221c2de r154fdc8  
    1 #include <stdlib.h>
    2 #include "bench.h"
    3 #include "cpp-stack.h"
     1#include <algorithm>
     2#include <fstream>
     3#include "bench.hpp"
     4#include "cpp-stack.hpp"
     5#include "cpp-pair.hpp"
     6#include "cpp-print.hpp"
    47
    58int main(int argc, char** argv) {
    6         srand(20171025);
     9        std::ofstream out{"cpp-out.txt"};
     10        int maxi = 0, vali = 42;
     11        stack<int> 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() ); )
     17        REPEAT_TIMED( "print_int", N/2, print( out, vali, ":", vali, "\n" ); )
    718
    8         stack<int> s;
    9 
    10         REPEAT_TIMED( "push_int",
    11                 s.push( rand() );
    12         )
     19        pair<bool, char> maxp = { false, '\0' }, valp = { true, 'a' };
     20        stack<pair<bool, char>> sp, tp;
     21       
     22        REPEAT_TIMED( "push_pair", N, sp.push( valp ); )
     23        TIMED( "copy_pair", tp = sp; )
     24        TIMED( "clear_pair", sp.clear(); )
     25        REPEAT_TIMED( "pop_pair", N, maxp = std::max( maxp, tp.pop() ); )
     26        REPEAT_TIMED( "print_pair", N/2, print( out, valp, ":", valp, "\n" ); )
    1327}
Note: See TracChangeset for help on using the changeset viewer.