package index
A platform-agnostic multi-level index for OCaml
Install
Dune Dependency
Authors
Maintainers
Sources
index-1.6.0.tbz
sha256=5e0c1f6cbd6e485cbbf2344c8f76de8a7869155355ae6edd5550c88da0661594
sha512=613fa206d1124b34259421f4ea978ce4e9404d78af3a687c1e406d88a5d481bd51465fafae58da9eb3e6a0b5408118b8a7dfe1fbb05ce8fed4b8b0a572beb99b
doc/src/index/stats.ml.html
Source file stats.ml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96
open! Import type t = { mutable bytes_read : int; mutable nb_reads : int; mutable bytes_written : int; mutable nb_writes : int; mutable nb_merge : int; mutable merge_durations : float list; mutable nb_replace : int; mutable replace_durations : float list; mutable nb_sync : int; mutable time_sync : float; mutable lru_hits : int; mutable lru_misses : int; } let fresh_stats () = { bytes_read = 0; nb_reads = 0; bytes_written = 0; nb_writes = 0; nb_merge = 0; merge_durations = []; nb_replace = 0; replace_durations = []; nb_sync = 0; time_sync = 0.0; lru_hits = 0; lru_misses = 0; } let stats = fresh_stats () let get () = stats let reset_stats () = stats.bytes_read <- 0; stats.nb_reads <- 0; stats.bytes_written <- 0; stats.nb_writes <- 0; stats.nb_merge <- 0; stats.merge_durations <- []; stats.nb_replace <- 0; stats.replace_durations <- []; stats.nb_sync <- 0; stats.time_sync <- 0.0; stats.lru_hits <- 0; stats.lru_misses <- 0 let incr_bytes_read n = stats.bytes_read <- stats.bytes_read + n let incr_bytes_written n = stats.bytes_written <- stats.bytes_written + n let incr_nb_reads () = stats.nb_reads <- succ stats.nb_reads let incr_nb_writes () = stats.nb_writes <- succ stats.nb_writes let incr_nb_merge () = stats.nb_merge <- succ stats.nb_merge let incr_nb_replace () = stats.nb_replace <- succ stats.nb_replace let incr_nb_sync () = stats.nb_sync <- succ stats.nb_sync let incr_nb_lru_hits () = stats.lru_hits <- succ stats.lru_hits let incr_nb_lru_misses () = stats.lru_misses <- succ stats.lru_misses let add_read n = incr_bytes_read n; incr_nb_reads () let add_write n = incr_bytes_written n; incr_nb_writes () module Make (Clock : Platform.CLOCK) = struct let replace_timer = ref (Clock.counter ()) let nb_replace = ref 0 let start_replace () = if !nb_replace = 0 then replace_timer := Clock.counter () let end_replace ~sampling_interval = nb_replace := !nb_replace + 1; if !nb_replace = sampling_interval then ( let span = Clock.count !replace_timer in let average = Mtime.Span.to_us span /. float_of_int !nb_replace in stats.replace_durations <- average :: stats.replace_durations; replace_timer := Clock.counter (); nb_replace := 0) let sync_with_timer f = let timer = Clock.counter () in f (); let span = Clock.count timer in stats.time_sync <- Mtime.Span.to_us span let drop_head l = if List.length l >= 10 then List.tl l else l let add_merge_duration span = let span = Mtime.Span.to_us span in stats.merge_durations <- drop_head stats.merge_durations @ [ span ] end
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>