Created
February 11, 2017 18:38
-
-
Save blackode/f07f9b02030857e457dd6d3df1f42ae4 to your computer and use it in GitHub Desktop.
Execution Time for function in elixir
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule ExecutionTime do | |
def time_of(function, args) do | |
{time, result} = :timer.tc(function, args) | |
IO.puts "Time: #{time}ms" | |
IO.puts "Result: #{result}" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
:timer.tc
returns the time in micro seconds.ms
is used for milliseconds whileµs
would be the correct symbol for microseconds (or dividetime
by 1000).