apoorv-2204
When benchmarking a function, what is measured?
If calling different modules and methods inside benchmarking functions also measures their execution also? if sending a message to a process for processing other things , does it include that processing of that process.
scenario = %{
“any” => fn _x → “I mean here” end)
}
Marked As Solved
benwilson512
Yes. Think of it this way:
The benchmark is just doing (basically):
start_time = System.now()
function()
end_time = System.now()
end_time - start_time
So if something delays the return of function() then it will delay end_time. If it does not delay the return of function() then it does not.
Also Liked
benwilson512
Yes. receive do blocks until it receives a message, which means it’ll block the return of the function, which means it’ll take more time in the benchmark.
Rik
From documentation https://elixir-lang.org/getting-started/processes.html#send-and-receive :
A timeout can also be specified:
iex> receive do
...> {:hello, msg} -> msg
...> after
...> 1_000 -> "nothing after 1s"
...> end
"nothing after 1s"
A timeout of 0 can be given when you already expect the message to be in the mailbox.
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #elixirconf-us
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #security
- #hex









