Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions bench.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ RUN git clone https://github.com/ocaml/opam-repository --depth 1
RUN git -C opam-repository fetch origin $OPAMREPOSHA
RUN git -C opam-repository checkout $OPAMREPOSHA
RUN opam init -n --disable-sandboxing ./opam-repository
RUN find "$(pwd)/opam-repository" -name opam -type f > /home/opam/all-opam-files
3 changes: 3 additions & 0 deletions master_changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@ users)

## Test

## Benchmarks
* Benchmark OpamSystem.read [#5900 @kit-ty-kate]

## Reftests
### Tests
* Add init scripts tests [#5864 @rjbou]
Expand Down
21 changes: 21 additions & 0 deletions tests/bench/bench.ml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,21 @@ let () =
launch "opam switch set-invariant core -n --sw two";
time_cmd ~exit:0 (fmt "%s install magic-trace -y --fake --sw two" bin)
in
let time_OpamSystem_read_10 =
let time_OpamSystem_read () =
let ic = Stdlib.open_in_bin "/home/opam/all-opam-files" in
let before = Unix.gettimeofday () in
let rec loop () =
match Stdlib.input_line ic with
| file -> ignore (OpamSystem.read file); loop ()
| exception End_of_file -> Unix.gettimeofday () -. before
in
loop ()
in
let n = 10 in
let l = List.init n (fun _ -> time_OpamSystem_read ()) in
List.fold_left (+.) 0.0 l /. float_of_int n
in
let json = fmt {|{
"results": [
{
Expand All @@ -52,6 +67,11 @@ let () =
"name": "Fake install with invariant",
"value": %f,
"units": "secs"
},
{
"name": "OpamSystem.read amortised over 10 runs",
"value": %f,
"units": "secs"
}
]
},
Expand All @@ -70,6 +90,7 @@ let () =
time_misspelled_cmd
time_install_cmd
time_install_cmd_w_invariant
time_OpamSystem_read_10
bin_size
in
print_endline json
2 changes: 1 addition & 1 deletion tests/bench/dune
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
(executable
(name bench)
(libraries unix))
(libraries unix opam-core))