X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=src%2Fmalloc%2Fbench.c;fp=src%2Fmalloc%2Fbench.c;h=28ae66d8dfda7997a0e4bb1427f292f2498b27c1;hb=dc655a9a438369fea59f6ee49bee874f71f82391;hp=0000000000000000000000000000000000000000;hpb=9d224cba6a348ca86bea2c6cb32a32d01c8bffbe;p=libc-test 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