Skip to content

Commit 6e07eb6

Browse files
committed
Measure the time to boot the CLI
1 parent 2db9796 commit 6e07eb6

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

lib/mix/lib/mix/cli.ex

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,14 @@ defmodule Mix.CLI do
88
Mix.start()
99

1010
if env_variable_activated?("MIX_QUIET"), do: Mix.shell(Mix.Shell.Quiet)
11-
if env_variable_activated?("MIX_DEBUG"), do: Mix.debug(true)
11+
12+
debug? =
13+
if env_variable_activated?("MIX_DEBUG") do
14+
Mix.debug(true)
15+
true
16+
else
17+
false
18+
end
1219

1320
if profile = System.get_env("MIX_PROFILE") do
1421
Mix.State.put(:profile, String.split(profile, ","))
@@ -22,6 +29,13 @@ defmodule Mix.CLI do
2229
:version ->
2330
display_version()
2431

32+
nil when debug? ->
33+
shell = Mix.shell()
34+
shell.info("-> Running mix CLI")
35+
{time, res} = :timer.tc(&proceed/1, [args])
36+
shell.info(["<- Ran mix CLI in ", Integer.to_string(div(time, 1000)), "ms"])
37+
res
38+
2539
nil ->
2640
proceed(args)
2741
end

lib/mix/lib/mix/task.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,7 @@ defmodule Mix.Task do
523523
task in Mix.State.get(:profile, []) ->
524524
shell = Mix.shell()
525525
shell.info(["-> Profiling mix ", task_to_string(task, args), project_to_string(proj)])
526-
Mix.Tasks.Profile.Eprof.profile(fun, warmup: false, set_on_spawn: false)
526+
Mix.Tasks.Profile.Tprof.profile(fun, warmup: false, set_on_spawn: false)
527527

528528
true ->
529529
fun.()

0 commit comments

Comments
 (0)