Skip to content

Instantly share code, notes, and snippets.

@damonvjanis
Last active October 21, 2021 13:14
Show Gist options
  • Save damonvjanis/59f2e5ed3f2e97c2b9e59da85297b3db to your computer and use it in GitHub Desktop.
Save damonvjanis/59f2e5ed3f2e97c2b9e59da85297b3db to your computer and use it in GitHub Desktop.
Profiles a function that throws vs one that returns
Mix.install([:benchee])
defmodule Profile do
def function_that_throws(input) do
throw(input)
catch
value -> value
end
def function_that_returns(input) do
input
end
end
Benchee.run(
%{
"throw" => fn -> Profile.function_that_throws(:test) end,
"return" => fn -> Profile.function_that_returns(:test) end
},
time: 10,
memory_time: 2
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment