package landmarks

  1. Overview
  2. Docs
A simple profiling library

Install

Dune Dependency

Authors

Maintainers

Sources

v1.5.tar.gz
md5=8656a2bd04456f8f18ef19af20c85f0c
sha512=b5f24973b1aabbf91c6e4f6ce594dfded10fa134e27d2e4adcc75543296f7d564725c6b8f345cbbf294a394828b2063aa74e6fe3c068574a7510d9ff78860a40

doc/src/landmarks.threads/landmark_threads.ml.html

Source file landmark_threads.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
include Landmark

let current_id = ref Thread.(id (self ()))

let check () =
  !current_id = Thread.(id (self ()))

let error operation =
  failwith (Printf.sprintf "%s: this operation can only be called by the thread that started the profiling" operation)

let increment ?times counter =
  if check () then
    increment ?times counter

let sample sampler value =
  if check () then
    sample sampler value

let enter lm =
  if check () then
    enter lm

let exit lm =
  if check () then
    exit lm

let wrap lm f x =
  if check () then
    wrap lm f x
  else f x

let unsafe_wrap lm f x =
  if check () then
    wrap lm f x
  else
    f x

let export ?label () =
  if check () then
    export ?label ()
  else
    error "export"

let reset () =
  if check () then
    reset ()
  else
    error "reset"

let export_and_reset ?label () =
  if check () then
    export_and_reset ?label ()
  else
    error "export_and_reset"

let start_profiling ?profiling_options () =
  current_id := Thread.(id (self ()));
  start_profiling ?profiling_options ()

let stop_profiling () =
  stop_profiling ()
OCaml

Innovation. Community. Security.