mirror of
https://github.com/justinethier/cyclone.git
synced 2025-07-09 22:17:33 +02:00
Added gc_print_stats
This commit is contained in:
parent
cb9db55a79
commit
1ce9fee354
2 changed files with 22 additions and 0 deletions
21
gc.c
21
gc.c
|
@ -212,6 +212,27 @@ gc_heap *gc_heap_create(size_t size, size_t max_size, size_t chunk_size)
|
||||||
return h;
|
return h;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void gc_print_stats(gc_heap *h)
|
||||||
|
{
|
||||||
|
gc_free_list *f;
|
||||||
|
unsigned int free, free_chunks, free_min, free_max;
|
||||||
|
for (; h; h = h->next) {
|
||||||
|
free = 0;
|
||||||
|
free_chunks = 0;
|
||||||
|
free_min = h->size;
|
||||||
|
free_max = 0;
|
||||||
|
for (f = h->free_list; f; f = f->next) {
|
||||||
|
free += f->size;
|
||||||
|
free_chunks++;
|
||||||
|
if (f->size < free_min) free_min = f->size;
|
||||||
|
if (f->size > free_max) free_max = f->size;
|
||||||
|
}
|
||||||
|
fprintf(stdout,
|
||||||
|
"Heap page size=%u, free=%u, free chunks=%u, min=%u, max=%u\n",
|
||||||
|
h->size, free, free_chunks, free_min, free_max);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Copy given object into given heap object
|
// Copy given object into given heap object
|
||||||
char *gc_copy_obj(object dest, char *obj, gc_thread_data *thd)
|
char *gc_copy_obj(object dest, char *obj, gc_thread_data *thd)
|
||||||
{
|
{
|
||||||
|
|
|
@ -403,6 +403,7 @@ void gc_initialize();
|
||||||
void gc_add_mutator(gc_thread_data *thd);
|
void gc_add_mutator(gc_thread_data *thd);
|
||||||
void gc_remove_mutator(gc_thread_data *thd);
|
void gc_remove_mutator(gc_thread_data *thd);
|
||||||
gc_heap *gc_heap_create(size_t size, size_t max_size, size_t chunk_size);
|
gc_heap *gc_heap_create(size_t size, size_t max_size, size_t chunk_size);
|
||||||
|
void gc_print_stats(gc_heap *h);
|
||||||
int gc_grow_heap(gc_heap *h, size_t size, size_t chunk_size);
|
int gc_grow_heap(gc_heap *h, size_t size, size_t chunk_size);
|
||||||
char *gc_copy_obj(object hp, char *obj, gc_thread_data *thd);
|
char *gc_copy_obj(object hp, char *obj, gc_thread_data *thd);
|
||||||
void *gc_try_alloc(gc_heap *h, size_t size, char *obj, gc_thread_data *thd);
|
void *gc_try_alloc(gc_heap *h, size_t size, char *obj, gc_thread_data *thd);
|
||||||
|
|
Loading…
Add table
Reference in a new issue