Created
February 8, 2017 13:47
-
-
Save obrok/0b77936477c43d467bfc296a86d10b2d to your computer and use it in GitHub Desktop.
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 Bench do | |
def bench do | |
:timer.tc(fn -> Enum.reduce(Range.new(0, 10000000), 0, &Kernel.+/2) end) |> IO.inspect | |
:timer.tc(fn -> Enum.reduce(Range.new(0, 10000000), 0, fn acc, n -> acc + n end) end) |> IO.inspect | |
end | |
end |
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
rindr:bench yapee$ MIX_ENV=prod mix compile | |
Compiling 1 file (.ex) | |
rindr:bench yapee$ MIX_ENV=prod mix run -e "Bench.bench" | |
{1846782, 50000005000000} | |
{1850227, 50000005000000} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment