aaron-thesisarm-ehcleanup-dtorsdeferred_resndemanglerenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumresolv-newwith_gc
Last change
on this file since 0d10090 was
0d10090,
checked in by Aaron Moss <a3moss@…>, 6 years ago
|
Add printing code to benchmark
|
-
Property mode set to
100644
|
File size:
1.1 KB
|
Line | |
---|
1 | #include <algorithm> |
---|
2 | #include <fstream> |
---|
3 | #include <stdlib.h> |
---|
4 | #include <utility> |
---|
5 | #include "bench.hpp" |
---|
6 | #include "cpp-stack.hpp" |
---|
7 | #include "cpp-print.hpp" |
---|
8 | |
---|
9 | int main(int argc, char** argv) { |
---|
10 | srand(20171025); |
---|
11 | |
---|
12 | stack<int> s; |
---|
13 | REPEAT_TIMED( "push_int", |
---|
14 | s.push( rand() ); |
---|
15 | ) |
---|
16 | |
---|
17 | stack<int> t; |
---|
18 | TIMED( "copy_int", |
---|
19 | t = s; |
---|
20 | ) |
---|
21 | |
---|
22 | TIMED( "clear_int", |
---|
23 | s.clear(); |
---|
24 | ) |
---|
25 | |
---|
26 | int max = 0; |
---|
27 | REPEAT_TIMED( "pop_int", |
---|
28 | max = std::max( max, t.pop() ); |
---|
29 | ) |
---|
30 | |
---|
31 | stack<std::pair<bool, char>> s2; |
---|
32 | REPEAT_TIMED( "push_bool_char", |
---|
33 | s2.push( std::pair<bool, char>{ rand() & 0x1, rand() & 0x7F } ); |
---|
34 | ) |
---|
35 | |
---|
36 | stack<std::pair<bool,char>> t2; |
---|
37 | TIMED( "copy_bool_char", |
---|
38 | t2 = s2; |
---|
39 | ) |
---|
40 | |
---|
41 | TIMED( "clear_bool_char", |
---|
42 | s2.clear(); |
---|
43 | ) |
---|
44 | |
---|
45 | std::pair<bool, char> max2 = { false, '\0' }; |
---|
46 | REPEAT_TIMED( "pop_bool_char", |
---|
47 | max2 = std::max( max2, t2.pop() ); |
---|
48 | ) |
---|
49 | |
---|
50 | std::ofstream out{"cpp-out.txt"}; |
---|
51 | REPEAT_TIMED( "print_int", |
---|
52 | print( out, rand(), ":", rand(), "\n" ); |
---|
53 | ) |
---|
54 | |
---|
55 | REPEAT_TIMED( "print_pair", |
---|
56 | print( out, std::pair<bool, char>{ rand() & 0x1, rand() & 0x7F }, ":", |
---|
57 | std::pair<bool, char>{ rand() & 0x1, rand() & 0x7F }, "\n" ); |
---|
58 | ) |
---|
59 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.