forked from mirage/mirage-clock
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
57 additions
and
48 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,33 @@ | ||
module C = Pclock | ||
module M = Mclock | ||
let (>>=) = Lwt.bind | ||
|
||
let print_time () = | ||
let d, ps = C.now_d_ps () in | ||
let print_time c = | ||
let d, ps = Pclock.now_d_ps c in | ||
Printf.printf "The time is %d days and %Ld picoseconds since the epoch.\n" d ps | ||
|
||
let print_offset () = match C.current_tz_offset_s () with | ||
let print_offset c = match Pclock.current_tz_offset_s c with | ||
| Some offset -> Printf.printf "The offset from UTC is %d minutes.\n" offset | ||
| None -> Printf.printf "Clock UTC offset unavailable\n" | ||
|
||
let print_period () = match C.period_d_ps () with | ||
let print_period c = match Pclock.period_d_ps c with | ||
| Some (d, ps) -> Printf.printf "The clock period is: %Ld picoseconds\n" ps | ||
| None -> Printf.printf "Clock period unavailable\n" | ||
|
||
let print_mtime () = | ||
Printf.printf "Monotonic clock says: %Ld nanoseconds\n" (M.elapsed_ns ()) | ||
let print_mtime c = | ||
Printf.printf "Monotonic clock says: %Ld nanoseconds\n" (Mclock.elapsed_ns c) | ||
|
||
let _ = | ||
print_mtime (); | ||
print_time (); | ||
print_time (); | ||
print_time (); | ||
print_offset (); | ||
print_period (); | ||
print_mtime (); | ||
let main () = | ||
let mclock = Mclock.connect () in | ||
Pclock.connect () >>= function | ||
`Ok clock -> ( | ||
print_mtime mclock; | ||
print_time clock; | ||
print_time clock; | ||
print_time clock; | ||
print_offset clock; | ||
print_period clock; | ||
print_mtime mclock; | ||
Lwt.return_unit | ||
) | ||
| `Error _ -> Lwt.return_unit | ||
|
||
let _ = Lwt_main.run (main ()) |
This file was deleted.
Oops, something went wrong.
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
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
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
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