-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Profiler return the return value of the function #11657
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
Profiler return the return value of the function #11657
Conversation
As discussed in: https://groups.google.com/g/elixir-lang-core/c/f0gP0It-yuU But basically: * right now no return value is documented/discussed so should not be relied upon * the original profiler themselves all return the return value, so it should be possible * I need it in Benchee 👼
|
|
||
| :eprof.start() | ||
| :eprof.profile([], fun, Keyword.get(opts, :matching, {:_, :_, :_})) | ||
| {:ok, return_value} = :eprof.profile([], fun, Keyword.get(opts, :matching, {:_, :_, :_})) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This bit is potentially dangerous, as it might return {:error, Reason} https://www.erlang.org/doc/man/eprof.html#profile-1
If tracing could be enabled for P and all processes in Rootset, the function returns {ok,Value} when Fun()/apply returns with the value Value, or {error,Reason} if Fun()/apply fails with exit reason Reason. Otherwise it returns {error, Reason} immediately.
It would be a rather hard failure here, on the other hand I'm not sure a possible error was handled gracefully before. Also not sure how to best "gracefully" handle it here.
Feedback welcome!
|
💚 💙 💜 💛 ❤️ |
|
@josevalim one small q if I may, I always kind of thought when providing default arguments it's basically seen as 2 different functions, hence I provided 2 type specs for them. Since you changed it I suspect I'm wrong, I just don't know why or/how 😅 If you had a minute to tell me or point me somewhere I'd really appreciate it! 💚 |
|
Yes, they are different functions! |

As discussed in: https://groups.google.com/g/elixir-lang-core/c/f0gP0It-yuU
But basically:
be relied upon
so it should be possible
Happy to make any kind of adjustments. I was thinking about introducing a behavior as all of these functions were very samey (and in fact in Benchee we rely on them being the same) but not sure it's needed here.
Thanks for all your work y'all! 💚
The bunny thanks thee!