3 void IoAddonsInit(IoObject
*context
);
8 #define IO_SHOW_STATS 1
14 #include <sys/resource.h>
16 double System_UserTime(void)
19 int r
= getrusage(0, &u
);
20 return r
== -1 ? -1 : u
.ru_utime
.tv_sec
+ (((double)u
.ru_utime
.tv_usec
)/1000000);
25 int main(int argc
, const char *argv
[])
31 size_t maxAllocatedBytes
;
39 IoState_setBindingsInitCallback(self
, (IoStateBindingsInitCallback
*)IoAddonsInit
);
42 IoState_argc_argv_(self
, argc
, argv
);
44 exitResult
= IoState_exitResult(self
);
47 maxAllocatedBytes
= io_maxAllocatedBytes();
48 collectorTime
= Collector_timeUsed(self
->collector
);
49 sweepCount
= self
->collector
->sweepCount
;
56 float totalTime
= (clock()-t1
)/(float)CLOCKS_PER_SEC
;
57 printf("[ %.3fs user %.3fs total %.1f%% gc %i sweeps %i frees %.3fmb max ]\n",
60 100.0*collectorTime
/totalTime
,
63 maxAllocatedBytes
/1048576.0);
65 if(io_allocatedBytes() != 0)
67 printf("warning: %i bytes in %i blocks not freed:\n\n",
68 (int)io_allocatedBytes(), (int)(io_allocs() - io_frees()));
73 printf("[ no memory leaks found ]\n");