2 * $DragonFly: src/tools/test/malloc/main.c,v 1.2 2003/11/07 14:38:38 eirikn Exp $
9 u_long NBUCKETS
= 2000;
11 u_long NSIZE
= (16*1024);
16 main(int argc
, char **argv
)
20 if (argc
> 1) NOPS
= strtoul(argv
[1],0,0);
21 if (argc
> 2) NBUCKETS
= strtoul(argv
[2],0,0);
22 if (argc
> 3) NSIZE
= strtoul(argv
[3],0,0);
23 printf("BRK(0)=%x ",sbrk(0));
24 foo
= malloc (sizeof *foo
* NBUCKETS
);
25 memset(foo
,0,sizeof *foo
* NBUCKETS
);
26 for (i
= 1; i
<= 4096; i
+=i
) {
27 for (j
= 0 ; j
< 40960/i
&& j
< NBUCKETS
; j
++) {
30 for (j
= 0 ; j
< 40960/i
&& j
< NBUCKETS
; j
++) {
36 for (i
= 0 ; i
< NOPS
; i
++) {
37 j
= random() % NBUCKETS
;
39 foo
[j
] = realloc(foo
[j
], k
& 1 ? 0 : k
);
43 printf("BRK(1)=%x ",sbrk(0));
44 for (j
= 0 ; j
< NBUCKETS
; j
++) {
50 printf("BRK(2)=%x NOPS=%lu NBUCKETS=%lu NSIZE=%lu\n",
51 sbrk(0),NOPS
,NBUCKETS
,NSIZE
);