Skip to content

Commit 3653413

Browse files
committed
Add a benchmark for opam install
1 parent 7f0272e commit 3653413

2 files changed

Lines changed: 44 additions & 0 deletions

File tree

master_changes.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ users)
148148

149149
## Benchmarks
150150
* Add an even larger real-world diff to benchmark `opam update` [#6567 @kit-ty-kate]
151+
* Add a benchmark for `opam install` [#6912 @kit-ty-kate]
151152

152153
## Reftests
153154
### Tests

tests/bench/bench.ml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,37 @@ let () =
136136
in
137137
List.fold_left (+.) 0.0 l /. float_of_int n
138138
in
139+
let time_install_core =
140+
Gc.compact ();
141+
launch (fmt "%s switch create -y eight ocaml-base-compiler.4.14.0" bin);
142+
launch (fmt "%s install --download-only -y core.v0.15.1" bin);
143+
launch "test -d ~/.opam/eight/.opam-switch/sources && rm -rf ~/.opam/eight/.opam-switch/sources";
144+
launch "test -d ~/.opam/eight/.opam-switch/build && rm -rf ~/.opam/eight/.opam-switch/build";
145+
time_cmd ~exit:0 (fmt "%s install -y core.v0.15.1" bin)
146+
in
147+
let time_install_big =
148+
Gc.compact ();
149+
launch (fmt "%s switch create nine --empty" bin);
150+
OpamSystem.write "/tmp/opam-bench-bigpkg/repo" {|opam-version: "2.0"
151+
|};
152+
OpamSystem.write "/tmp/opam-bench-bigpkg/packages/a.1/opam" {|opam-version: "2.0"
153+
url {
154+
src: "https://github.com/ocaml/opam-repository/archive/refs/tags/2025-01-before-archiving-phase1.tar.gz"
155+
checksum: "md5=215a5261ad8358e34eb3222b83c4c8be"
156+
}
157+
|};
158+
OpamSystem.write "/tmp/opam-bench-bigpkg/packages/b.1/opam" {|opam-version: "2.0"
159+
build: ["rm" "-r" "packages"]
160+
url {
161+
src: "https://github.com/ocaml/opam-repository/archive/refs/tags/2025-01-before-archiving-phase1.tar.gz"
162+
checksum: "md5=215a5261ad8358e34eb3222b83c4c8be"
163+
}
164+
|};
165+
launch (fmt "%s repo add tmp /tmp/opam-bench-bigpkg" bin);
166+
let res = time_cmd ~exit:0 (fmt "%s install a.1 b.1" bin) in
167+
launch (fmt "%s repo remove tmp -a" bin);
168+
res
169+
in
139170
let init_root tmp_root_dir repo =
140171
launch (fmt "rm -rf %s" tmp_root_dir);
141172
launch (fmt "mkdir -p %s" tmp_root_dir);
@@ -279,6 +310,16 @@ let () =
279310
"name": "OpamStd.String.split amortised over 10 runs",
280311
"value": %f,
281312
"units": "secs"
313+
},
314+
{
315+
"name": "opam install core.v0.15.1",
316+
"value": %f,
317+
"units": "secs"
318+
},
319+
{
320+
"name": "opam install large-pkg large-pkg2",
321+
"value": %f,
322+
"units": "secs"
282323
}
283324
]
284325
},
@@ -363,6 +404,8 @@ let () =
363404
time_show_raw
364405
time_show_precise
365406
time_OpamStd_String_split_10
407+
time_install_core
408+
time_install_big
366409
time_update_no_diff_local
367410
time_update_no_diff_git
368411
time_update_small_diff_local

0 commit comments

Comments
 (0)