summaryrefslogtreecommitdiffstats
path: root/tools/test/malloc
diff options
context:
space:
mode:
authorphk <phk@FreeBSD.org>1996-10-26 08:22:09 +0000
committerphk <phk@FreeBSD.org>1996-10-26 08:22:09 +0000
commitbd28e36b038e8d15462f77cf751261467a219e69 (patch)
tree1a9547bdc0586f5d4790a40c9e49127c66dac7eb /tools/test/malloc
parentbc3c11514b9e6319e04755157fccbbba199daf87 (diff)
downloadFreeBSD-src-bd28e36b038e8d15462f77cf751261467a219e69.zip
FreeBSD-src-bd28e36b038e8d15462f77cf751261467a219e69.tar.gz
Update this to match my version.
Diffstat (limited to 'tools/test/malloc')
-rw-r--r--tools/test/malloc/Makefile25
-rw-r--r--tools/test/malloc/main.c (renamed from tools/test/malloc/malloc.c)20
2 files changed, 21 insertions, 24 deletions
diff --git a/tools/test/malloc/Makefile b/tools/test/malloc/Makefile
index 3cf3ee0..0db5977 100644
--- a/tools/test/malloc/Makefile
+++ b/tools/test/malloc/Makefile
@@ -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>
diff --git a/tools/test/malloc/malloc.c b/tools/test/malloc/main.c
index a865b9e..4d1d380 100644
--- a/tools/test/malloc/malloc.c
+++ b/tools/test/malloc/main.c
@@ -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++) {
OpenPOWER on IntegriCloud