Created
June 9, 2016 20:50
-
-
Save net/e729afd66a0005904be106187a71ea69 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 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