Skip to content

Commit 27e56dc

Browse files
committed
Apply review suggestions
1 parent bdea259 commit 27e56dc

File tree

2 files changed

+17
-13
lines changed

2 files changed

+17
-13
lines changed

lib/mix/lib/mix/tasks/profile.tprof.ex

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -227,17 +227,23 @@ defmodule Mix.Tasks.Profile.Tprof do
227227
fun.()
228228
end
229229

230-
tprof_module().start()
231230
matching = Keyword.get(opts, :matching, {:_, :_, :_})
232231
set_on_spawn = Keyword.get(opts, :set_on_spawn, true)
233232
type = Keyword.get(opts, :type, :time)
234233

235234
sort_by =
236235
case Keyword.get(opts, :sort) do
237-
nil -> :measurement
238-
:calls -> :calls
239-
^type -> :measurement
240-
other -> Mix.raise("Incompatible sort option `#{other}` with type `#{type}`")
236+
nil ->
237+
:measurement
238+
239+
:calls ->
240+
:calls
241+
242+
^type ->
243+
:measurement
244+
245+
other ->
246+
Mix.raise("Incompatible sort option #{inspect(other)} with type #{inspect(type)}")
241247
end
242248

243249
tprof_type = to_tprof_type(type)
@@ -252,8 +258,6 @@ defmodule Mix.Tasks.Profile.Tprof do
252258

253259
inspected = tprof_module().inspect({tprof_type, traces}, :process, sort_by)
254260

255-
tprof_module().stop()
256-
257261
results =
258262
inspected
259263
|> Enum.map(fn {pid, {^tprof_type, measurement_total, call_results}} ->
@@ -284,11 +288,11 @@ defmodule Mix.Tasks.Profile.Tprof do
284288
end
285289

286290
defp get_filter_value!(type, time, _memory) when is_integer(time) and type != :time do
287-
Mix.raise("Incompatible use of time option with type `#{type}`")
291+
Mix.raise("Incompatible use of time option with type #{inspect(type)}")
288292
end
289293

290294
defp get_filter_value!(type, _time, memory) when is_integer(memory) and type != :memory do
291-
Mix.raise("Incompatible use of memory option with type `#{type}`")
295+
Mix.raise("Incompatible use of memory option with type #{inspect(type)}")
292296
end
293297

294298
defp get_filter_value!(:time, time, nil) when is_integer(time), do: time

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -153,25 +153,25 @@ defmodule Mix.Tasks.Profile.TprofTest do
153153

154154
test "errors on incompatible options", context do
155155
in_tmp(context.test, fn ->
156-
message = "Incompatible sort option `memory` with type `time`"
156+
message = "Incompatible sort option :memory with type :time"
157157

158158
assert_raise Mix.Error, message, fn ->
159159
capture_io(fn -> Tprof.run(["-e", @expr, "--sort", "memory"]) end)
160160
end
161161

162-
message = "Incompatible sort option `time` with type `calls`"
162+
message = "Incompatible sort option :time with type :calls"
163163

164164
assert_raise Mix.Error, message, fn ->
165165
capture_io(fn -> Tprof.run(["-e", @expr, "--type", "calls", "--sort", "time"]) end)
166166
end
167167

168-
message = "Incompatible use of memory option with type `time`"
168+
message = "Incompatible use of memory option with type :time"
169169

170170
assert_raise Mix.Error, message, fn ->
171171
capture_io(fn -> Tprof.run(["-e", @expr, "--time", "1", "--memory", "2"]) end)
172172
end
173173

174-
message = "Incompatible use of time option with type `calls`"
174+
message = "Incompatible use of time option with type :calls"
175175

176176
assert_raise Mix.Error, message, fn ->
177177
capture_io(fn -> Tprof.run(["-e", @expr, "--type", "calls", "--time", "1"]) end)

0 commit comments

Comments
 (0)