@@ -46,6 +46,8 @@ defmodule Mix.Tasks.Profile.Tprof do
46
46
* `--time` - filters out any results that took lower than specified (in µs), the `type` needs to be `time`
47
47
* `--memory` - filters out any results that used less memory than specified (in words), the `type` needs to be `memory`
48
48
* `--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`.
49
51
* `--eval`, `-e` - evaluates the given code
50
52
* `--require`, `-r` - requires pattern before running the command
51
53
* `--parallel`, `-p` - makes all requires parallel
@@ -152,6 +154,7 @@ defmodule Mix.Tasks.Profile.Tprof do
152
154
time: :integer ,
153
155
memory: :integer ,
154
156
sort: :string ,
157
+ report: :string ,
155
158
start: :boolean ,
156
159
archives_check: :boolean ,
157
160
warmup: :boolean ,
@@ -211,6 +214,10 @@ defmodule Mix.Tasks.Profile.Tprof do
211
214
defp parse_opt ( { :type , "memory" } ) , do: { :type , :memory }
212
215
defp parse_opt ( { :type , other } ) , do: Mix . raise ( "Invalid type option: #{ other } " )
213
216
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
+
214
221
defp parse_opt ( { :sort , "time" } ) , do: { :sort , :time }
215
222
defp parse_opt ( { :sort , "calls" } ) , do: { :sort , :calls }
216
223
defp parse_opt ( { :sort , "memory" } ) , do: { :sort , :memory }
@@ -238,6 +245,8 @@ defmodule Mix.Tasks.Profile.Tprof do
238
245
`type` needs to be `:memory`
239
246
* `:sort` - sort the results by `:calls`, `:per_call` or by the value of `type`
240
247
(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`.
241
250
* `:warmup` - if the code should be warmed up before profiling (default: `true`)
242
251
* `:set_on_spawn` - if newly spawned processes should be measured (default: `true`)
243
252
@@ -259,6 +268,7 @@ defmodule Mix.Tasks.Profile.Tprof do
259
268
matching = Keyword . get ( opts , :matching , { :_ , :_ , :_ } )
260
269
set_on_spawn = Keyword . get ( opts , :set_on_spawn , true )
261
270
type = Keyword . get ( opts , :type , :time )
271
+ report = Keyword . get ( opts , :report , :process )
262
272
263
273
sort_by =
264
274
case Keyword . get ( opts , :sort ) do
@@ -288,7 +298,7 @@ defmodule Mix.Tasks.Profile.Tprof do
288
298
report: :return
289
299
} )
290
300
291
- inspected = tprof_module ( ) . inspect ( { tprof_type , traces } , :process , sort_by )
301
+ inspected = tprof_module ( ) . inspect ( { tprof_type , traces } , report , sort_by )
292
302
293
303
results =
294
304
inspected
0 commit comments