Skip to content

Commit

Permalink
Benchmark OpamSystem.read
Browse files Browse the repository at this point in the history
  • Loading branch information
kit-ty-kate committed Mar 28, 2024
1 parent 6beeb02 commit 871ab1c
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 1 deletion.
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
16 changes: 16 additions & 0 deletions tests/bench/bench.ml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,16 @@ 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 =
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 json = fmt {|{
"results": [
{
Expand All @@ -52,6 +62,11 @@ let () =
"name": "Fake install with invariant",
"value": %f,
"units": "secs"
},
{
"name": "OpamSystem.read",
"value": %f,
"units": "secs"
}
]
},
Expand All @@ -70,6 +85,7 @@ let () =
time_misspelled_cmd
time_install_cmd
time_install_cmd_w_invariant
time_OpamSystem_read
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))

0 comments on commit 871ab1c

Please sign in to comment.