Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI/bench: add install bench #5574

Merged
merged 4 commits into from
Jun 9, 2023
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 .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ on:
- '.github/scripts/**'
- '.github/workflows/main.yml'
- 'tests/**'
- '!tests/bench/**'
- 'shell/'
# paths-ignore:
# - 'release/**'
Expand Down
6 changes: 5 additions & 1 deletion bench.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,8 @@ RUN make cold
USER root
RUN install ./opam /usr/local/bin/
USER opam
RUN opam init -n --disable-sandboxing git+https://github.com/ocaml/opam-repository#26770281fa1ea8b13aab979c1dfbd326e9ab512c
ENV OPAMREPOSHA 26770281fa1ea8b13aab979c1dfbd326e9ab512c
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
1 change: 1 addition & 0 deletions master_changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,7 @@ users)
* Update crowbar with compare functions [#4918 @rjbou]
* No more mute test debug output (level < 0) if `--readonly` is given with `--debug-level` [#5476 @rjbou]
* Setup benchmarking using current-bench [#5525 @kit-ty-kate]
* Add install benchs [#5574 @rjbou]

## Reftests
### Tests
Expand Down
32 changes: 31 additions & 1 deletion tests/bench/bench.ml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,26 @@ let time_cmd ~exit cmd =
let () =
let bin = "./opam" in
let bin_size = (Unix.stat bin).st_size in
let launch cmd =
let code = Sys.command cmd in
if not (Int.equal code 0) then
failwith (fmt "Preliminary command %S exited with error code %d" cmd code)
in
let time_misspelled_cmd =
(* NOTE: https://github.com/ocaml/opam/issues/5479 *)
time_cmd ~exit:2 (fmt "%s sitch" bin)
in
let time_install_cmd =
(* NOTE: https://github.com/ocaml/opam/issues/5502 *)
launch "opam switch create one --empty";
time_cmd ~exit:0 (fmt "%s install magic-trace -y --fake --sw one" bin)
in
let time_install_cmd_w_invariant =
(* NOTE: https://github.com/ocaml/opam/issues/5502 *)
launch "opam switch create two --empty";
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 json = fmt {|{
"results": [
{
Expand All @@ -26,6 +42,16 @@ let () =
"name": "Misspelled command",
"value": %f,
"units": "secs"
},
{
"name": "Fake install with no invariant",
"value": %f,
"units": "secs"
},
{
"name": "Fake install with invariant",
"value": %f,
"units": "secs"
}
]
},
Expand All @@ -40,6 +66,10 @@ let () =
]
}
]
}|} time_misspelled_cmd bin_size
}|}
time_misspelled_cmd
time_install_cmd
time_install_cmd_w_invariant
bin_size
in
print_endline json