Skip to content

Commit f190517

Browse files
authored
Merge pull request #4 from ocaml-multicore/prepare-release-0.0.3
Prepare release
2 parents 6ac5250 + d12057b commit f190517

File tree

9 files changed

+87
-60
lines changed

9 files changed

+87
-60
lines changed

.ocamlformat

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
version = 0.24.1
2+
profile = conventional
3+
4+
ocaml-version = 5.0.0

CHANGES.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## v0.0.3 (2023-02-17)
2+
3+
* Add memory_size function (@crackcomm, #1)
4+
* Change memory_size return type to int (@crackcomm, #2)
5+
* Fix build with dune 3.6 (@emillon, #3)
6+
17
## v0.0.2 (2022-07-07)
28

39
* Moved repository

hdr_histogram.opam

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,7 @@ build: [
3333
"@doc" {with-doc}
3434
]
3535
]
36+
available: [
37+
(arch = "x86_64" | arch = "arm64")
38+
]
3639
dev-repo: "git+https://github.com/ocaml-multicore/hdr_histogram_ocaml.git"

lib/dune

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,18 @@
44
(install_c_headers hdr_histogram)
55
(foreign_archives hdr_histogram)
66
; ctypes backward compatibility shims warn sometimes; suppress them
7-
(flags (:standard -w -9-27))
7+
(flags
8+
(:standard -w -9-27))
89
(ctypes
910
(external_library_name hdr_histogram)
1011
(deps hdr_histogram.h dllhdr_histogram.so libhdr_histogram.a)
1112
(build_flags_resolver
12-
(vendored
13+
(vendored
1314
; hack: multiple -I directives to work around cc commands being run from
1415
; different relative directories. Is there a cleaner way to do this?
1516
(c_flags :standard "-Ilib" "-I.")))
16-
(headers (include "hdr_histogram.h"))
17+
(headers
18+
(include "hdr_histogram.h"))
1719
(type_description
1820
(instance Type)
1921
(functor Type_description))
@@ -27,17 +29,25 @@
2729
(data_only_dirs libhdr_histogram)
2830

2931
(rule
30-
(deps (source_tree libhdr_histogram))
31-
(targets dllhdr_histogram.so libhdr_histogram.a hdr_histogram.h)
32-
(action (no-infer
33-
(progn (chdir libhdr_histogram
34-
(progn (run mkdir -p _build)
35-
(chdir _build
36-
(progn (run cmake ..)
37-
(run make)))))
38-
(copy libhdr_histogram/_build/src/libhdr_histogram_static.a
39-
libhdr_histogram.a)
40-
(copy libhdr_histogram/_build/src/libhdr_histogram.so
41-
dllhdr_histogram.so)
42-
(copy libhdr_histogram/include/hdr/hdr_histogram.h
43-
hdr_histogram.h)))))
32+
(deps
33+
(source_tree libhdr_histogram))
34+
(targets dllhdr_histogram.so libhdr_histogram.a hdr_histogram.h)
35+
(action
36+
(no-infer
37+
(progn
38+
(chdir
39+
libhdr_histogram
40+
(progn
41+
(run mkdir -p _build)
42+
(chdir
43+
_build
44+
(progn
45+
(run cmake ..)
46+
(run make)))))
47+
(copy
48+
libhdr_histogram/_build/src/libhdr_histogram_static.a
49+
libhdr_histogram.a)
50+
(copy
51+
libhdr_histogram/_build/src/libhdr_histogram.so
52+
dllhdr_histogram.so)
53+
(copy libhdr_histogram/include/hdr/hdr_histogram.h hdr_histogram.h)))))

lib/function_description.ml

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,31 +8,32 @@ module Types = Types_generated
88
module Functions (F : Ctypes.FOREIGN) = struct
99
open F
1010

11-
let hdr_init = foreign "hdr_init"
12-
(int64_t @-> int64_t @-> int @-> ptr (ptr Types.hdr_histogram) @->
13-
returning int)
11+
let hdr_init =
12+
foreign "hdr_init"
13+
(int64_t @-> int64_t @-> int
14+
@-> ptr (ptr Types.hdr_histogram)
15+
@-> returning int)
1416

15-
let hdr_record_value = foreign "hdr_record_value"
16-
(ptr Types.hdr_histogram @-> int64_t @-> returning bool)
17+
let hdr_record_value =
18+
foreign "hdr_record_value"
19+
(ptr Types.hdr_histogram @-> int64_t @-> returning bool)
1720

18-
let hdr_close = foreign "hdr_close"
19-
(ptr Types.hdr_histogram @-> returning void)
21+
let hdr_close =
22+
foreign "hdr_close" (ptr Types.hdr_histogram @-> returning void)
2023

21-
let hdr_value_at_percentile = foreign "hdr_value_at_percentile"
22-
(ptr Types.hdr_histogram @-> double @-> returning int64_t)
24+
let hdr_value_at_percentile =
25+
foreign "hdr_value_at_percentile"
26+
(ptr Types.hdr_histogram @-> double @-> returning int64_t)
2327

24-
let hdr_min = foreign "hdr_min"
25-
(ptr Types.hdr_histogram @-> returning int64_t)
28+
let hdr_min = foreign "hdr_min" (ptr Types.hdr_histogram @-> returning int64_t)
29+
let hdr_max = foreign "hdr_max" (ptr Types.hdr_histogram @-> returning int64_t)
2630

27-
let hdr_max = foreign "hdr_max"
28-
(ptr Types.hdr_histogram @-> returning int64_t)
31+
let hdr_mean =
32+
foreign "hdr_mean" (ptr Types.hdr_histogram @-> returning double)
2933

30-
let hdr_mean = foreign "hdr_mean"
31-
(ptr Types.hdr_histogram @-> returning double)
34+
let hdr_stddev =
35+
foreign "hdr_stddev" (ptr Types.hdr_histogram @-> returning double)
3236

33-
let hdr_stddev = foreign "hdr_stddev"
34-
(ptr Types.hdr_histogram @-> returning double)
35-
36-
let hdr_get_memory_size = foreign "hdr_get_memory_size"
37-
(ptr Types.hdr_histogram @-> returning size_t)
37+
let hdr_get_memory_size =
38+
foreign "hdr_get_memory_size" (ptr Types.hdr_histogram @-> returning size_t)
3839
end

lib/hdr_histogram.ml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
open Ctypes
2-
32
module Types = Types_generated
43

54
type t = Types.hdr_histogram structure ptr
65

7-
let init ~lowest_discernible_value ~highest_trackable_value
8-
~significant_figures =
9-
let h = allocate (ptr Types.hdr_histogram)
10-
(from_voidp (Types.hdr_histogram) null)
6+
let init ~lowest_discernible_value ~highest_trackable_value ~significant_figures
7+
=
8+
let h =
9+
allocate (ptr Types.hdr_histogram) (from_voidp Types.hdr_histogram null)
1110
in
12-
let res = C.Function.hdr_init (Int64.of_int lowest_discernible_value)
13-
(Int64.of_int highest_trackable_value)
14-
significant_figures h
11+
let res =
12+
C.Function.hdr_init
13+
(Int64.of_int lowest_discernible_value)
14+
(Int64.of_int highest_trackable_value)
15+
significant_figures h
1516
in
1617
assert (res = 0);
17-
let h' : t = !@ h in
18+
let h' : t = !@h in
1819
h'
1920

2021
let record_value h v = C.Function.hdr_record_value h (Int64.of_int v)
21-
2222
let close h = C.Function.hdr_close h
2323

2424
let value_at_percentile h p =

lib/hdr_histogram.mli

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
type t
22
(** The type of histogram values *)
33

4-
val init : lowest_discernible_value:int
5-
-> highest_trackable_value:int
6-
-> significant_figures:int
7-
-> t
4+
val init :
5+
lowest_discernible_value:int ->
6+
highest_trackable_value:int ->
7+
significant_figures:int ->
8+
t
89
(** Initialize a new histogram *)
910

1011
val record_value : t -> int -> bool

lib/type_description.ml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
open Ctypes
22

33
module Types (F : Ctypes.TYPE) = struct
4-
(* open F *)
4+
(* open F *)
55

66
type hdr_histogram
7+
78
let hdr_histogram : hdr_histogram structure typ = structure "hdr_histogram"
89
end

test/test1.ml

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,22 @@ open Hdr_histogram
33
let print_percentiles h =
44
let percentiles = [| 50.0; 75.0; 90.0; 99.0; 99.9; 99.99; 99.999; 100.0 |] in
55
Fun.flip Array.iter percentiles (fun p ->
6-
Printf.printf "%f \t %d\n" p (value_at_percentile h p))
6+
Printf.printf "%f \t %d\n" p (value_at_percentile h p))
77

88
let main () =
9-
let h = init ~lowest_discernible_value:1 ~highest_trackable_value:100_000_000
10-
~significant_figures:3
9+
let h =
10+
init ~lowest_discernible_value:1 ~highest_trackable_value:100_000_000
11+
~significant_figures:3
1112
in
12-
for i=1000 to 100_000 do
13-
for _j =1 to 1000 do
13+
for i = 1000 to 100_000 do
14+
for _j = 1 to 1000 do
1415
ignore @@ record_value h i
15-
done;
16+
done
1617
done;
17-
for i=100_001 to 110_000 do
18+
for i = 100_001 to 110_000 do
1819
for _j = 1 to 100 do
1920
ignore @@ record_value h i
20-
done;
21+
done
2122
done;
2223
print_percentiles h;
2324
close h

0 commit comments

Comments
 (0)