Skip to content

Commit 3e93951

Browse files
committed
Sort and verify CALLS column instead of PER CALL column.
Added assertion for the result sort order. Signed-off-by: Tomasz Marek Sulima <[email protected]>
1 parent b2aa983 commit 3e93951

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

lib/mix/test/mix/tasks/profile.tprof_test.exs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,21 +85,20 @@ defmodule Mix.Tasks.Profile.TprofTest do
8585
in_tmp(context.test, fn ->
8686
result =
8787
capture_io(fn ->
88-
Tprof.run(["--type", "memory", "--sort", "per_call", "-e", @expr])
88+
Tprof.run(["--type", "memory", "--sort", "calls", "-e", @expr])
8989
end)
9090

9191
[_warmup, _profile_results, _columns, _total, first, second, _profile_done, ""] =
9292
String.split(result, ~r/\n+/)
9393

9494
list =
9595
Enum.map([first, second], fn row ->
96-
[mfa, _calls, _percent, _words, per_call] = String.split(row, ~r/\s+/)
97-
{mfa, String.to_float(per_call)}
96+
[mfa, calls, _percent, _words, _per_call] = String.split(row, ~r/\s+/)
97+
{String.to_integer(calls), mfa}
9898
end)
9999

100-
assert list == Enum.sort_by(list, &elem(&1, 1))
101-
assert List.keymember?(list, "Enum.each/2", 0)
102-
assert List.keymember?(list, ":erlang.integer_to_binary/1", 0)
100+
assert list == Enum.sort(list)
101+
assert list == [{1, "Enum.each/2"}, {5, ":erlang.integer_to_binary/1"}]
103102
end)
104103
end
105104

0 commit comments

Comments
 (0)