diff --git a/src/malloc/Makefile b/src/malloc/Makefile new file mode 100644 index 0000000..ee4552b --- /dev/null +++ b/src/malloc/Makefile @@ -0,0 +1 @@ +include ../../Makefile.inc diff --git a/src/malloc/bench.c b/src/malloc/bench.c new file mode 100644 index 0000000..28ae66d --- /dev/null +++ b/src/malloc/bench.c @@ -0,0 +1,141 @@ +#include +#include +#include +#include +#include "test.h" + +void bench_malloc_sparse() { + void *p[N]; + size_t i; + for (i=0; i1) for (i=1; i; i = (i+1999)%N) + free(p[i]); + free(p[0]); + free(p); +} + +void bench_malloc_big1() { + void *p[N]; + size_t i; + for (i=0; i1) for (i=1; i; i = (i+1999)%(sizeof p/sizeof *p)) + free(p[i]); + free(p[0]); +} + + +#define SH_COUNT 300 +#define PV_COUNT 300 +#define MAX_SZ 500 +#define DEF_SZ 40 + +struct foo { + void *mem; + pthread_mutex_t lock; +}; + +static unsigned rng(unsigned *r) +{ + return *r = *r * 1103515245 + 12345; +} + + +static void *stress(void *arg) +{ + struct foo *foo = arg; + unsigned r = (unsigned)pthread_self(); + int i, j; + size_t sz; + void *p; + + for (i=0; i +#include +#include +#include "test.h" + +void bench_stdio_putcgetc() { + FILE *f = tmpfile(); + size_t i; + size_t cs = 0; + + for (i=0; i