Update this to match my version.

This commit is contained in:
Poul-Henning Kamp 1996-10-26 08:22:09 +00:00
parent 7bd7818f1c
commit 9ee40678bb
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=19192
2 changed files with 21 additions and 24 deletions

View File

@ -1,23 +1,14 @@
PROG= malloc
SRCS= main.c malloc.c
.PATH: ${.CURDIR}/../../../lib/libc/stdlib
NOMAN= sorry
libcmalloc:
make clean
make "CFLAGS=-O2"
mv malloc libcmalloc
test: malloc
@echo
@csh -x -c "time ./libcmalloc 500000 2000 8192"
@csh -x -c "time ./libcmalloc 50000000 2000 8192"
@csh -x -c "time ./libcmalloc 500000 14000 8192"
@csh -x -c "time ./libcmalloc 20000000 20000 2048"
gnumalloc:
make clean
make "CFLAGS=-lgnumalloc -O2"
mv malloc gnumalloc
@csh -x -c "time ./gnumalloc 500000 2000 8192"
@csh -x -c "time ./gnumalloc 50000000 2000 8192"
@csh -x -c "time ./gnumalloc 500000 14000 8192"
@csh -x -c "time ./gnumalloc 20000000 20000 2048"
@csh -x -c "time ./malloc 500000 2000 8192"
@csh -x -c "time ./malloc 50000000 2000 8192"
@csh -x -c "time ./malloc 500000 14000 8192"
@csh -x -c "time ./malloc 20000000 20000 2048"
.include <bsd.prog.mk>

View File

@ -19,16 +19,22 @@ main(int argc, char **argv)
printf("BRK(0)=%x ",sbrk(0));
foo = malloc (sizeof *foo * NBUCKETS);
memset(foo,0,sizeof *foo * NBUCKETS);
for (i = 0 ; i < NOPS ; i++) {
j = rand() % NBUCKETS;
if (foo[j]) {
for (i = 1; i <= 4096; i+=i) {
for (j = 0 ; j < 40960/i && j < NBUCKETS; j++) {
foo[j] = malloc(i);
}
for (j = 0 ; j < 40960/i && j < NBUCKETS; j++) {
free(foo[j]);
foo[j] = 0;
} else {
k = rand() % NSIZE;
foo[j] = malloc(k);
}
}
for (i = 0 ; i < NOPS ; i++) {
j = random() % NBUCKETS;
k = random() % NSIZE;
foo[j] = realloc(foo[j], k & 1 ? 0 : k);
if (foo[j])
foo[j][0] = 1;
}
}
printf("BRK(1)=%x ",sbrk(0));
for (j = 0 ; j < NBUCKETS ; j++) {