From 48ca86003970a8f368d57eac0e31c1b9147a9255 Mon Sep 17 00:00:00 2001 From: Kate Date: Wed, 25 Sep 2024 20:54:05 +0100 Subject: [PATCH] Add benchmarks for opam show --- master_changes.md | 1 + tests/bench/bench.ml | 42 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/master_changes.md b/master_changes.md index 5247c0c2808..fdaf3330240 100644 --- a/master_changes.md +++ b/master_changes.md @@ -138,6 +138,7 @@ users) ## Test ## Benchmarks + * Add benchmarks for `opam show` [#6212 @kit-ty-kate] ## Reftests ### Tests diff --git a/tests/bench/bench.ml b/tests/bench/bench.ml index d55c07edcee..0d03bb7d340 100644 --- a/tests/bench/bench.ml +++ b/tests/bench/bench.ml @@ -99,6 +99,24 @@ let () = launch (fmt "%s switch create six --empty" bin); time_cmd ~exit:0 (fmt "%s list --installed --short --safe --color=never ocp-indent ocp-index merlin" bin) in + launch (fmt "%s switch create seven --empty" bin); + launch (fmt "%s install -y --fake dune" bin); + let time_show_installed = + Gc.compact (); + time_cmd ~exit:0 (fmt "%s show dune" bin) + in + let time_show_with_depexts = + Gc.compact (); + time_cmd ~exit:0 (fmt "%s show conf-llvm" bin) + in + let time_show_raw = + Gc.compact (); + time_cmd ~exit:0 (fmt "%s show --raw conf-llvm" bin) + in + let time_show_precise = + Gc.compact (); + time_cmd ~exit:0 (fmt "%s show --raw conf-llvm.14.0.6" bin) + in let json = fmt {|{ "results": [ { @@ -148,6 +166,26 @@ let () = "name": "opam list --installed on non-installed packages", "value": %f, "units": "secs" + }, + { + "name": "opam show of an installed package", + "value": %f, + "units": "secs" + }, + { + "name": "opam show with depexts", + "value": %f, + "units": "secs" + }, + { + "name": "opam show --raw pkgname", + "value": %f, + "units": "secs" + }, + { + "name": "opam show --raw pkgname.version", + "value": %f, + "units": "secs" } ] }, @@ -172,6 +210,10 @@ let () = time_install_check_installed time_install_check_not_installed time_list_installed_noninstalled_packages + time_show_installed + time_show_with_depexts + time_show_raw + time_show_precise bin_size in print_endline json