#include #include "bench.h" #include "c-stack.h" void* copy_int( void* p ) { int* q = malloc(sizeof(int)); *q = *(int*)p; return q; } int main(int argc, char** argv) { srand(20171025); struct stack s = new_stack(); REPEAT_TIMED( "push_int", int* x = malloc(sizeof(int)); *x = rand(); push_stack(&s, x); ) struct stack t; TIMED( "copy_int", copy_stack(&t, &s, copy_int); ) TIMED( "clear_int", clear_stack(&s); ) int sum; REPEAT_TIMED( "pop_int", int* x = pop_stack(&t); sum += *x; free(x); ) }