package windtrap

  1. Overview
  2. Docs
One library for all your OCaml tests

Install

dune-project
 Dependency

Authors

Maintainers

Sources

windtrap-0.1.0.tbz
sha256=2241b294b24ed5d56ea8b834d296e6fabc5dbdd924a89f51c14b00da66c50a25
sha512=c6cf83028bb09d0f2afeb38fce6825620873a6bbeff4b5b77e928bc2fc69262d49fe341961cba2b451c9dc9bd0df414f06bb73020c7131b125c6abd85c6bc5dd

doc/src/windtrap.clock/clock.ml.html

Source file clock.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
(*---------------------------------------------------------------------------
   Copyright (c) 2015 The mtime programmers. All rights reserved.
   Copyright (c) 2026 Invariant Systems. All rights reserved.
   SPDX-License-Identifier: ISC
  ---------------------------------------------------------------------------*)

external elapsed_ns : unit -> int64 = "ocaml_windtrap_clock_elapsed_ns"

(* Force a call at module load time to initialize the C-side clock origin. *)
let () = ignore (elapsed_ns ())

type counter = int64

let counter () = elapsed_ns ()

let count start =
  let now = elapsed_ns () in
  Int64.sub now start

let count_s start =
  let ns = count start in
  Int64.to_float ns /. 1_000_000_000.