Skip to content

Commit 76fec7e

Browse files
authored
Implement mix profile.tprof (#13605)
1 parent ae5be31 commit 76fec7e

File tree

3 files changed

+634
-9
lines changed

3 files changed

+634
-9
lines changed

lib/mix/lib/mix/tasks/profile.eprof.ex

+4-9
Original file line numberDiff line numberDiff line change
@@ -224,9 +224,9 @@ defmodule Mix.Tasks.Profile.Eprof do
224224
calls_opt = Keyword.get(opts, :calls, 0)
225225
time_opt = Keyword.get(opts, :time, 0)
226226

227-
call_results
228-
|> Stream.filter(fn {_mfa, {count, _time}} -> count >= calls_opt end)
229-
|> Stream.filter(fn {_mfa, {_count, time}} -> time >= time_opt end)
227+
Enum.filter(call_results, fn {_mfa, {count, time}} ->
228+
count >= calls_opt and time >= time_opt
229+
end)
230230
end
231231

232232
defp sort_results(call_results, opts) do
@@ -307,15 +307,10 @@ defmodule Mix.Tasks.Profile.Eprof do
307307
max_lengths = Enum.map(header, &String.length/1)
308308

309309
Enum.reduce(rows, max_lengths, fn row, max_lengths ->
310-
Stream.map(row, &String.length/1)
311-
|> Stream.zip(max_lengths)
312-
|> Enum.map(&max/1)
310+
Enum.zip_with(row, max_lengths, fn cell, length -> String.length(cell) |> max(length) end)
313311
end)
314312
end
315313

316-
defp max({a, b}) when a >= b, do: a
317-
defp max({_, b}), do: b
318-
319314
@format "~-*s ~*s ~*s ~*s ~*s~n"
320315

321316
defp print_row(row, column_lengths) do

0 commit comments

Comments
 (0)