source: doc/generic_types/evaluation/cpp-bench.cpp @ ff178ee

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

Update benchmarks to include stack of pairs

  • Property mode set to 100644
File size: 771 bytes
Line 
1#include <algorithm>
2#include <stdlib.h>
3#include <utility>
4#include "bench.hpp"
5#include "cpp-stack.hpp"
6
7int main(int argc, char** argv) {
8        srand(20171025);
9
10        stack<int> s;
11        REPEAT_TIMED( "push_int",
12                s.push( rand() );
13        )
14
15        stack<int> t;
16        TIMED( "copy_int", 
17                t = s;
18        )
19
20        TIMED( "clear_int", 
21                s.clear();
22        )
23
24        int max = 0;
25        REPEAT_TIMED( "pop_int",
26                max = std::max( max, t.pop() );
27        )
28
29        stack<std::pair<bool, char>> s2;
30        REPEAT_TIMED( "push_bool_char",
31                s2.push( std::pair<bool, char>{ rand() & 0x1, rand() & 0x7F } );
32        )
33
34        stack<std::pair<bool,char>> t2;
35        TIMED( "copy_bool_char", 
36                t2 = s2;
37        )
38
39        TIMED( "clear_bool_char", 
40                s2.clear();
41        )
42
43        std::pair<bool, char> max2 = { false, '\0' };
44        REPEAT_TIMED( "pop_bool_char",
45                max2 = std::max( max2, t2.pop() );
46        )
47}
Note: See TracBrowser for help on using the repository browser.