Last active
April 7, 2016 02:26
-
-
Save ckhrysze/015a8748910c8d467bd2a6e2c832a670 to your computer and use it in GitHub Desktop.
Quick benchmark of ways to remove the last element of a list in elixir
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 PopBench do | |
use Benchfella | |
@list Enum.to_list(1..1000) | |
bench "reverse" do | |
[_head|tail] = Enum.reverse(@list) | |
Enum.reverse(tail) | |
end | |
bench "take" do | |
Enum.take(@list, length(@list) - 1) | |
end | |
bench "drop" do | |
Enum.drop(@list, -1) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment