source: doc/generic_types/evaluation/c-bench.c@ 122aecd

ADT aaron-thesis arm-eh ast-experimental cleanup-dtors deferred_resn demangler enum forall-pointer-decay jacob/cs343-translation jenkins-sandbox new-ast new-ast-unique-expr new-env no_list persistent-indexer pthread-emulation qualifiedEnum resolv-new with_gc
Last change on this file since 122aecd was 122aecd, checked in by Aaron Moss <a3moss@…>, 9 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
5void* copy_int( void* p ) {
6 int* q = malloc(sizeof(int));
7 *q = *(int*)p;
8 return q;
9}
10
11int 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.