Created
March 9, 2022 17:16
-
-
Save stedolan/f84fa523a97d7f695fc930ea9388177d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type alloc_count = { mutable total: float } | |
let allocs = { total = 0. } | |
let[@inline never] count txt = | |
let now = int_of_float (Gc.minor_words () -. allocs.total) in | |
Printf.printf "%20s: %d\n" txt now; | |
allocs.total <- Gc.minor_words () | |
let v = Sys.opaque_identity (ref 42) | |
let () = allocs.total <- Gc.minor_words () | |
include struct | |
let x = !v | |
let y = !v | |
end | |
let () = count "no signature" | |
include (struct | |
let a = !v | |
let b = !v | |
end : sig val a : int val b : int end) | |
let () = count "trivial coercion" | |
include (struct | |
let c = !v | |
let d = !v | |
end : sig val c : int end) | |
let () = count "prefix coercion" | |
include (struct | |
let c = !v | |
let d = !v | |
end : sig val d : int end) | |
let () = count "reordering coercion" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment