@@ -70,6 +70,7 @@ let solve_lock_dir
7070 workspace
7171 ~local_packages
7272 ~project_pins
73+ ~print_perf_stats
7374 version_preference
7475 solver_env_from_current_system
7576 lock_dir_path
@@ -94,6 +95,7 @@ let solve_lock_dir
9495 ~unset_solver_vars_from_context:
9596 (unset_solver_vars_of_workspace workspace ~lock_dir_path )
9697 in
98+ let time_start = Unix. gettimeofday () in
9799 let * repos =
98100 let repo_map = repositories_of_workspace workspace in
99101 let repo_names =
@@ -105,6 +107,7 @@ let solve_lock_dir
105107 get_repos repo_map ~repositories: (repositories_of_lock_dir workspace ~lock_dir_path )
106108 in
107109 let * pins = resolve_project_pins project_pins in
110+ let time_solve_start = Unix. gettimeofday () in
108111 progress_state := Some Progress_indicator.Per_lockdir.State. Solving ;
109112 Dune_pkg.Opam_solver. solve_lock_dir
110113 solver_env
@@ -119,19 +122,30 @@ let solve_lock_dir
119122 ~constraints: (constraints_of_workspace workspace ~lock_dir_path )
120123 >> = function
121124 | Error (`Diagnostic_message message ) -> Fiber. return (Error (lock_dir_path, message))
122- | Ok { lock_dir; files; pinned_packages } ->
125+ | Ok { lock_dir; files; pinned_packages; num_expanded_packages } ->
126+ let time_end = Unix. gettimeofday () in
127+ let maybe_perf_stats =
128+ if print_perf_stats
129+ then
130+ [ Pp. nop
131+ ; Pp. textf " Expanded packages: %d" num_expanded_packages
132+ ; Pp. textf " Updated repos in: %.2fs" (time_solve_start -. time_start)
133+ ; Pp. textf " Solved dependencies in: %.2fs" (time_end -. time_solve_start)
134+ ]
135+ else []
136+ in
123137 let summary_message =
124138 User_message. make
125- [ Pp. tag
126- User_message.Style. Success
127- (Pp. textf
128- " Solution for %s:"
129- (Path.Source. to_string_maybe_quoted lock_dir_path))
130- ; (match Package_name.Map. values lock_dir.packages with
131- | [] ->
132- Pp. tag User_message.Style. Warning @@ Pp. text " (no dependencies to lock)"
133- | packages -> pp_packages packages)
134- ]
139+ ( Pp. tag
140+ User_message.Style. Success
141+ (Pp. textf
142+ " Solution for %s:"
143+ (Path.Source. to_string_maybe_quoted lock_dir_path))
144+ :: (match Package_name.Map. values lock_dir.packages with
145+ | [] ->
146+ Pp. tag User_message.Style. Warning @@ Pp. text " (no dependencies to lock)"
147+ | packages -> pp_packages packages)
148+ :: maybe_perf_stats)
135149 in
136150 progress_state := None ;
137151 let + lock_dir = Lock_dir. compute_missing_checksums ~pinned_packages lock_dir in
@@ -145,6 +159,7 @@ let solve
145159 ~solver_env_from_current_system
146160 ~version_preference
147161 ~lock_dirs
162+ ~print_perf_stats
148163 =
149164 let open Fiber.O in
150165 (* a list of thunks that will perform all the file IO side
@@ -166,6 +181,7 @@ let solve
166181 workspace
167182 ~local_packages
168183 ~project_pins
184+ ~print_perf_stats
169185 version_preference
170186 solver_env_from_current_system
171187 lockdir_path
@@ -198,7 +214,7 @@ let project_pins =
198214 Pin_stanza.DB. combine_exn acc (Dune_project. pins project))
199215;;
200216
201- let lock ~version_preference ~lock_dirs_arg =
217+ let lock ~version_preference ~lock_dirs_arg ~ print_perf_stats =
202218 let open Fiber.O in
203219 let * solver_env_from_current_system =
204220 Dune_pkg.Sys_poll. make ~path: (Env_path. path Stdune.Env. initial)
@@ -223,15 +239,18 @@ let lock ~version_preference ~lock_dirs_arg =
223239 ~solver_env_from_current_system
224240 ~version_preference
225241 ~lock_dirs
242+ ~print_perf_stats
226243;;
227244
228245let term =
229246 let + builder = Common.Builder. term
230247 and + version_preference = Version_preference. term
231- and + lock_dirs_arg = Pkg_common.Lock_dirs_arg. term in
248+ and + lock_dirs_arg = Pkg_common.Lock_dirs_arg. term
249+ and + print_perf_stats = Arg. (value & flag & info [ " print-perf-stats" ]) in
232250 let builder = Common.Builder. forbid_builds builder in
233251 let common, config = Common. init builder in
234- Scheduler. go ~common ~config (fun () -> lock ~version_preference ~lock_dirs_arg )
252+ Scheduler. go ~common ~config (fun () ->
253+ lock ~version_preference ~lock_dirs_arg ~print_perf_stats )
235254;;
236255
237256let info =
0 commit comments