Created
March 26, 2014 17:47
-
-
Save smondet/9789147 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 lwt_monitor_info = | |
let open Lwt in | |
let started = ref false in | |
let previous = ref (None : float option) in | |
let reads = ref [] in | |
fun () -> | |
begin match !started with | |
| false -> | |
Lwt.ignore_result begin | |
let rec loop () = | |
let time = Time.(now () |> to_float) in | |
begin match !previous with | |
| None -> previous := Some time | |
| Some p -> | |
(* if time -. p > !maximum then maximum := time -. p else (); *) | |
reads := (time, time -. p) :: !reads; | |
if List.length !reads > 10 then ( | |
reads := List.sort | |
~cmp:(fun a b -> Float.compare (snd b) (snd a)) !reads | |
|> (fun l -> List.take l 10); | |
); | |
previous := Some time; | |
end; | |
Lwt_main.yield () >>= fun () -> | |
loop () | |
in | |
loop () | |
end; | |
started := true; | |
| true -> (); | |
end; | |
let open Html5 in | |
div [ | |
pcdataf "Maximal unavailability:"; | |
ul (List.map !reads ~f:(fun (date, delay) -> | |
li [pcdataf "%s (%.3f): %f" | |
Time.(of_float date |> to_string) date delay])); | |
pcdataf "Features:"; | |
ul (List.map features ~f:(fun f -> | |
li [pcdataf "%s: %b" (feature_to_string f) (Lwt_sys.have f)])); | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment