package core
Module Gc.For_testingSource
measure_allocation f measures the words allocated by running f ()
Source
val measure_and_log_allocation :
(Base.Unit.t -> 'a) ->
'a * Allocation_report.t * Allocation_log.t Base.List.tmeasure_and_log_allocation f logs each allocation that f () performs, as well as reporting the total. (This can be slow if f allocates heavily).
This function is only supported since OCaml 4.11. On prior versions, the function always returns an empty log.
is_zero_alloc f runs f () and returns true if it does not allocate, or false otherwise. is_zero_alloc does not allocate.
prepare_heap_to_count_minor_allocation sets up the heap so that one can subsequently measure minor allocation via:
let minor_words_before = Gc.minor_words () in
(* ... do stuff ... *)
let minor_words_after = Gc.minor_words () in
let minor_words_allocated = minor_words_after - minor_words_before inWithout calling prepare_heap_to_count_minor_allocation, the resulting count may be inaccurate.