ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsdeferred_resndemanglerenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumresolv-newwith_gc
Last change
on this file since 87c5f40 was
87c5f40,
checked in by Aaron Moss <a3moss@…>, 7 years ago
|
Update benchmarks to include stack of pairs
|
-
Property mode set to
100644
|
File size:
881 bytes
|
Rev | Line | |
---|
[87c5f40] | 1 | #include <algorithm> |
---|
[b276be5] | 2 | #include <stdlib.h> |
---|
| 3 | #include "bench.hpp" |
---|
| 4 | #include "cpp-vstack.hpp" |
---|
[87c5f40] | 5 | #include "object.hpp" |
---|
[b276be5] | 6 | |
---|
| 7 | int main(int argc, char** argv) { |
---|
| 8 | srand(20171025); |
---|
| 9 | |
---|
| 10 | stack s; |
---|
| 11 | REPEAT_TIMED( "push_int", |
---|
| 12 | s.push( std::make_unique<integer>( rand() ) ); |
---|
| 13 | ) |
---|
| 14 | |
---|
| 15 | stack t; |
---|
| 16 | TIMED( "copy_int", |
---|
| 17 | t = s; |
---|
| 18 | ) |
---|
| 19 | |
---|
| 20 | TIMED( "clear_int", |
---|
| 21 | s.clear(); |
---|
| 22 | ) |
---|
| 23 | |
---|
[87c5f40] | 24 | integer max; |
---|
[b276be5] | 25 | REPEAT_TIMED( "pop_int", |
---|
[87c5f40] | 26 | max = std::max( max, t.pop()->as<integer>() ); |
---|
| 27 | ) |
---|
| 28 | |
---|
| 29 | stack s2; |
---|
| 30 | REPEAT_TIMED( "push_bool_char", |
---|
| 31 | s2.push( std::make_unique<pair>( std::make_unique<boolean>( rand() & 0x1 ), |
---|
| 32 | std::make_unique<character>( rand() & 0x7F ) ) ); |
---|
| 33 | ) |
---|
| 34 | |
---|
| 35 | stack t2; |
---|
| 36 | TIMED( "copy_bool_char", |
---|
| 37 | t2 = s2; |
---|
| 38 | ) |
---|
| 39 | |
---|
| 40 | TIMED( "clear_bool_char", |
---|
| 41 | s2.clear(); |
---|
| 42 | ) |
---|
| 43 | |
---|
| 44 | pair max2 = { std::make_unique<boolean>(false), std::make_unique<character>('\0') }; |
---|
| 45 | REPEAT_TIMED( "pop_bool_char", |
---|
| 46 | max2 = std::max( max2, t2.pop()->as<pair>() ); |
---|
[b276be5] | 47 | ) |
---|
| 48 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.