Created
February 11, 2025 11:33
-
-
Save stedolan/b0e8d75402daa18dbffe53c00cf6e620 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
let table = Array.init 10_000 (fun _ -> Bytes.make 1_000 'a') | |
let writes = | |
Option.map bool_of_string (Sys.getenv_opt "WRITES") | |
|> Option.value ~default:false | |
let[@inline never] f () = | |
List.init (Array.length table) (fun i -> | |
let buf = table.(i) in | |
if writes then table.(i) <- buf; | |
Bytes.get buf 42) | |
let () = | |
for i = 1 to 10_000 do | |
ignore (Sys.opaque_identity (f ())) | |
done; | |
let stat = Gc.quick_stat () in | |
Printf.printf "%15s: %b\n%15s: %.0f\n%15s: %.0f\n%15s: %d\n%15s: %d\n" | |
"writes" writes | |
"minor_words" stat.minor_words | |
"major_words" stat.major_words | |
"cycles" stat.major_collections | |
"heap_words" stat.top_heap_words |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment