@@ -46,6 +46,8 @@ defmodule Mix.Tasks.Profile.Tprof do
4646 * `--time` - filters out any results that took lower than specified (in µs), the `type` needs to be `time`
4747 * `--memory` - filters out any results that used less memory than specified (in words), the `type` needs to be `memory`
4848 * `--sort` - sorts the results by `calls`, `per_call` or by the value of `type` (default: the value of `type`)
49+ * `--report` - returns the per-process breakdown when `process`, or the total for all processes when `total` (default: `process`).
50+ Always `total` when `type` is `calls`.
4951 * `--eval`, `-e` - evaluates the given code
5052 * `--require`, `-r` - requires pattern before running the command
5153 * `--parallel`, `-p` - makes all requires parallel
@@ -152,6 +154,7 @@ defmodule Mix.Tasks.Profile.Tprof do
152154 time: :integer ,
153155 memory: :integer ,
154156 sort: :string ,
157+ report: :string ,
155158 start: :boolean ,
156159 archives_check: :boolean ,
157160 warmup: :boolean ,
@@ -211,6 +214,10 @@ defmodule Mix.Tasks.Profile.Tprof do
211214 defp parse_opt ( { :type , "memory" } ) , do: { :type , :memory }
212215 defp parse_opt ( { :type , other } ) , do: Mix . raise ( "Invalid type option: #{ other } " )
213216
217+ defp parse_opt ( { :report , "process" } ) , do: { :report , :process }
218+ defp parse_opt ( { :report , "total" } ) , do: { :report , :total }
219+ defp parse_opt ( { :report , other } ) , do: Mix . raise ( "Invalid report option: #{ other } " )
220+
214221 defp parse_opt ( { :sort , "time" } ) , do: { :sort , :time }
215222 defp parse_opt ( { :sort , "calls" } ) , do: { :sort , :calls }
216223 defp parse_opt ( { :sort , "memory" } ) , do: { :sort , :memory }
@@ -238,6 +245,8 @@ defmodule Mix.Tasks.Profile.Tprof do
238245 `type` needs to be `:memory`
239246 * `:sort` - sort the results by `:calls`, `:per_call` or by the value of `type`
240247 (default: the value of `type`)
248+ * `:report` - returns the per-process breakdown when `:process`, or the total for all
249+ processes when `:total` (default: `:process`). Always `:total` when `type` is `:calls`.
241250 * `:warmup` - if the code should be warmed up before profiling (default: `true`)
242251 * `:set_on_spawn` - if newly spawned processes should be measured (default: `true`)
243252
@@ -259,6 +268,7 @@ defmodule Mix.Tasks.Profile.Tprof do
259268 matching = Keyword . get ( opts , :matching , { :_ , :_ , :_ } )
260269 set_on_spawn = Keyword . get ( opts , :set_on_spawn , true )
261270 type = Keyword . get ( opts , :type , :time )
271+ report = Keyword . get ( opts , :report , :process )
262272
263273 sort_by =
264274 case Keyword . get ( opts , :sort ) do
@@ -288,7 +298,7 @@ defmodule Mix.Tasks.Profile.Tprof do
288298 report: :return
289299 } )
290300
291- inspected = tprof_module ( ) . inspect ( { tprof_type , traces } , :process , sort_by )
301+ inspected = tprof_module ( ) . inspect ( { tprof_type , traces } , report , sort_by )
292302
293303 results =
294304 inspected
0 commit comments