| 1 | (************************************************************************) |
| 2 | (* * The Rocq Prover / The Rocq Development Team *) |
| 3 | (* v * Copyright INRIA, CNRS and contributors *) |
| 4 | (* <O___,, * (see version control and CREDITS file for authors & dates) *) |
| 5 | (* \VV/ **************************************************************) |
| 6 | (* // * This file is distributed under the terms of the *) |
| 7 | (* * GNU Lesser General Public License Version 2.1 *) |
| 8 | (* * (see LICENSE file for the text of the license) *) |
| 9 | (************************************************************************) |
| 10 | |
| 11 | (** {6 Physical size of an ocaml value.} |
| 12 | |
| 13 | These functions explore objects recursively and may allocate a lot. *) |
| 14 | |
| 15 | val size : 'a -> int |
| 16 | (** Physical size of an object in words. *) |
| 17 | |
| 18 | val size_b : 'a -> int |
| 19 | (** Same as [size] in bytes. *) |
| 20 | |
| 21 | val size_kb : 'a -> int |
| 22 | (** Same as [size] in kilobytes. *) |
| 23 | |
| 24 | (** {6 Physical size of an ocaml value with sharing.} *) |
| 25 | |
| 26 | (** This time, all the size of objects are computed with respect |
| 27 | to a larger object containing them all, and we only count |
| 28 | the new blocks not already seen earlier in the left-to-right |
| 29 | visit of the englobing object. *) |
| 30 | |
| 31 | (** Provides the global object in which we'll search shared sizes *) |
| 32 | |
| 33 | val register_shared_size : 'a -> unit |
| 34 | |
| 35 | (** Shared size (in word) of an object with respect to the global object |
| 36 | given by the last [register_shared_size]. *) |
| 37 | |
| 38 | val shared_size_of_obj : 'a -> int |
| 39 | |
| 40 | (** Same, with an object indicated by its occurrence in the global |
| 41 | object. The very same object could have a zero size or not, depending |
| 42 | of the occurrence we're considering in the englobing object. |
| 43 | For speaking of occurrences, we use an [int list] for a path |
| 44 | of field indexes (leftmost = deepest block, rightmost = top block of the |
| 45 | global object). *) |
| 46 | |
| 47 | val shared_size_of_pos : int list -> int |
| 48 | |
| 49 | (** {6 Logical size of an OCaml value.} *) |
| 50 | |
| 51 | val obj_stats : 'a -> int * int * int |
| 52 | (** Return the (logical) value size, the string size, and the maximum depth of |
| 53 | the object. This loops on cyclic structures. *) |
| 54 | |
| 55 | (** {6 Total size of the allocated ocaml heap. } *) |
| 56 | |
| 57 | val heap_size : unit -> int |
| 58 | (** Heap size, in words. *) |
| 59 | |
| 60 | val heap_size_kb : unit -> int |
| 61 | (** Heap size, in kilobytes. *) |