Skip to content

Instantly share code, notes, and snippets.

@obrok
Created February 8, 2017 13:47
Show Gist options
  • Save obrok/0b77936477c43d467bfc296a86d10b2d to your computer and use it in GitHub Desktop.
Save obrok/0b77936477c43d467bfc296a86d10b2d to your computer and use it in GitHub Desktop.
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
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