Skip to content

Commit

Permalink
Merge pull request #313 from samoht/master
Browse files Browse the repository at this point in the history
Tweak the stats reporting a little bit
  • Loading branch information
samoht committed Apr 29, 2015
2 parents 925b5a3 + df9e020 commit c2a10eb
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions src/stats.ml
@@ -1,31 +1,33 @@
let (>>=) = Lwt.bind

let delay = 60. *. 2.
let history = 10_000
let history = 100

let html_of_stat t =
let open Gc in
let k f =
let str = Printf.sprintf "%.0fk" (f /. 1000.) in
let str = Printf.sprintf "%dk" (f / 1_000) in
Cow.Html.of_string str
in
let m f =
let str = Printf.sprintf "%.0fm" (f /. 1_000_000.) in
Cow.Html.of_string str
in
<:html<
<tr>
<td>$k t.minor_words$</td>
<td>$k t.major_words$</td>
<td>$int:t.minor_collections$</td>
<td>$int:t.major_collections$</td>
<td>$m (Gc.allocated_bytes ())$</td>
<td>$k t.heap_words$</td>
<td>$k t.live_words$</td>
</tr>
>>

let html_of_stats ts =
<:html<
<table>
<tr>
<th>Minor Words</th>
<th>Major Words</th>
<th>Minor Collections</th>
<th>Major Collections</th>
<th>Allocated Bytes</th>
<th>Heap Words</th>
<th>Live Words</th>
</tr>
$list:List.map html_of_stat ts$
</table>
Expand All @@ -35,7 +37,7 @@ let stats = Queue.create ()

let start ~sleep =
let gather () =
let stat = Gc.quick_stat () in
let stat = Gc.stat () in
if Queue.length stats >= history then ignore (Queue.pop stats);
Queue.push stat stats
in
Expand Down

0 comments on commit c2a10eb

Please sign in to comment.