Skip to content

Instantly share code, notes, and snippets.

@net
Created June 9, 2016 20:50
Show Gist options
  • Save net/e729afd66a0005904be106187a71ea69 to your computer and use it in GitHub Desktop.
Save net/e729afd66a0005904be106187a71ea69 to your computer and use it in GitHub Desktop.
defmodule Random do
use Benchfella
@list ~w(a b c d e f g h i j k l m n o p)
@tuple List.to_tuple(@list)
bench "tuple" do
_ = elem(@tuple, :random.uniform(16) - 1)
:ok
end
bench "list" do
_ = Enum.random(@list)
:ok
end
end
# ## Random
# tuple 10000000 0.35 µs/op
# list 500000 8.76 µs/op
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment