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 122aecd was
122aecd,
checked in by Aaron Moss <a3moss@…>, 7 years ago
|
Expand benchmarks
|
-
Property mode set to
100644
|
File size:
542 bytes
|
Line | |
---|
1 | #include <stdlib.h> |
---|
2 | #include "bench.h" |
---|
3 | #include "c-stack.h" |
---|
4 | |
---|
5 | void* copy_int( void* p ) { |
---|
6 | int* q = malloc(sizeof(int)); |
---|
7 | *q = *(int*)p; |
---|
8 | return q; |
---|
9 | } |
---|
10 | |
---|
11 | int main(int argc, char** argv) { |
---|
12 | srand(20171025); |
---|
13 | |
---|
14 | struct stack s = new_stack(); |
---|
15 | REPEAT_TIMED( "push_int", |
---|
16 | int* x = malloc(sizeof(int)); |
---|
17 | *x = rand(); |
---|
18 | push_stack(&s, x); |
---|
19 | ) |
---|
20 | |
---|
21 | struct stack t; |
---|
22 | TIMED( "copy_int", |
---|
23 | copy_stack(&t, &s, copy_int); |
---|
24 | ) |
---|
25 | |
---|
26 | TIMED( "clear_int", |
---|
27 | clear_stack(&s); |
---|
28 | ) |
---|
29 | |
---|
30 | int sum; |
---|
31 | REPEAT_TIMED( "pop_int", |
---|
32 | int* x = pop_stack(&t); |
---|
33 | sum += *x; |
---|
34 | free(x); |
---|
35 | ) |
---|
36 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.