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 hidden or 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.tcreturns the time in micro seconds.msis used for milliseconds whileµswould be the correct symbol for microseconds (or dividetimeby 1000).