Mix profile.fprof -e "Mix.Tasks.Test.run([])"?

I expect to see some my functions in profile summary but none of them present and weird 0 seconds 0 failures displayed.

$ mix profile.fprof -e "Mix.Tasks.Test.run([])"
Warmup...


Finished in 5.3 seconds
21 tests, 0 failures

Randomized with seed 795674
Reading trace data...
.......

Finished in 0.00 seconds
0 failures

Randomized with seed 795674
......
End of trace!
Processing data...
Creating output...
Done!

 
                                                                   CNT    ACC (ms)    OWN (ms)     
Total                                                             9372      21.446      18.417     
:suspend                                                           213      40.238       0.000     
:gen.do_for_proc/2                                                 152      23.637       0.361     
:gen.call/4                                                        148      22.821       0.228     
anonymous fn/4 in :gen.call/4                                      148      22.099       0.199     
:gen.do_call/4                                                     148      21.900       1.125     
:fprof.apply_start_stop/4                                            0      21.446       0.011     
anonymous fn/0 in :elixir_compiler_1.__FILE__/1                      1      21.433       0.002     
Mix.Tasks.Test.run/1                                                 1      21.431       0.041     
:proc_lib.init_p/5                                                   5      19.676       0.066     
:proc_lib.init_p_do_apply/3                                          5      19.192       0.032     
:erlang.apply/2                                                     11      17.533       0.042     
Code.require_file/1                                                  8      15.593       0.015     
Code.require_file/2                                                  8      15.578       0.038     
anonymous fn/2 in Kernel.ParallelRequire.spawn_requires/5            7      15.440       0.086     
Code.find_file/2                                                     8      15.009       0.039     
:gen_server.call/3                                                  35      13.930       0.099     
:file.call/2                                                        20      12.984       0.093     
:gen.init_it/6                                                       4      12.906       0.007     
:gen.init_it2/7                                                      4      12.899       0.011     
Mix.Utils.extract_files/2                                            2      12.665       0.005     
Enum.flat_map/2                                                      2      12.609       0.002     
Enum.flat_map_list/2                                                 4      12.607       0.011     
anonymous fn/2 in Mix.Utils.extract_files/2                          2      12.594       0.008     
Path.wildcard/1                                                      2      12.431       0.004     
Path.wildcard/2                                                      2      12.427       0.014     
:filelib.wildcard/2                                                  2      12.301       0.006     
:filelib.do_wildcard/3                                               2      12.295       0.009     
:filelib.do_wildcard_1/2                                             2      11.704       0.002     
:filelib.do_wildcard_2/4                                            25      11.702       0.036     
:filelib.do_wildcard_3/4                                            53      11.695       0.159     
:filelib.do_double_star/6                                           60      11.693       0.277  

Can someone explain why it happens? And maybe anyone know how to profile against test suite?

3 Likes

Did you ever figure this out?

No. Despite that I already forgot about this question, I’m still interested in an answer.

Oh, I know what’s happening. Profile task runs code two times, and the first time it does it to warm the execution. And second time it shows 0 seconds and 0 failures, because the test mix task designed in such way that it prevents to run same tests twice, so it just skips.

1 Like

interesting. But, did you figure out how to profile your code in a test environment? I think that’d be awesome.

1 Like

Nowadays you can pass --no-warmup option to your profiler invocation!

Hope that helps.

3 Likes