Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use :erlang.fun_info/2 instead of :erlang.fun_info/1 #147

Merged
merged 1 commit into from
Dec 19, 2023
Merged

Use :erlang.fun_info/2 instead of :erlang.fun_info/1 #147

merged 1 commit into from
Dec 19, 2023

Conversation

ypconstante
Copy link
Contributor

:erlang.fun_info/1 calls :erlang.fun_info/2 for each function information, since we need only the arity we can just get this information directly for a small performance improvement.

❯ mix profile.fprof -e ":erlang.fun_info(&Function.identity/1, :arity)"
...

                                                                   CNT    ACC (ms)    OWN (ms)     
Total                                                                3       0.011       0.011     
:fprof.apply_start_stop/4                                            0       0.011       0.006     
anonymous fn/0 in :elixir_compiler_1.__FILE__/1                      1       0.005       0.004     
:erlang.fun_info/2                                                   1       0.001       0.001     
:undefined                                                           0       0.000       0.000     
:suspend                                                             1       0.000       0.000     

❯ mix profile.fprof -e ":erlang.fun_info(&Function.identity/1)"
...
                                                                   CNT    ACC (ms)    OWN (ms)     
Total                                                               24       0.043       0.043     
:fprof.apply_start_stop/4                                            0       0.043       0.006     
anonymous fn/0 in :elixir_compiler_1.__FILE__/1                      1       0.037       0.002     
:erlang.fun_info/1                                                   1       0.035       0.002     
:erlang.fun_info_1/3                                                11       0.033       0.023     
:erlang.fun_info/2                                                  10       0.010       0.010     
:undefined                                                           0       0.000       0.000     
:suspend                                                             1       0.000       0.000     

@josevalim josevalim merged commit 877b86f into dashbitco:master Dec 19, 2023
1 of 2 checks passed
@josevalim
Copy link
Member

💚 💙 💜 💛 ❤️

@ypconstante ypconstante deleted the optimize-get-arity branch December 19, 2023 11:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants