Skip to content

Instantly share code, notes, and snippets.

@blackode
Created February 11, 2017 18:38
Show Gist options
  • Save blackode/f07f9b02030857e457dd6d3df1f42ae4 to your computer and use it in GitHub Desktop.
Save blackode/f07f9b02030857e457dd6d3df1f42ae4 to your computer and use it in GitHub Desktop.
Execution Time for function in elixir
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
@freelon
Copy link

freelon commented Dec 1, 2021

:timer.tc returns the time in micro seconds. ms is used for milliseconds while µs would be the correct symbol for microseconds (or divide time by 1000).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment