Skip to content

Instantly share code, notes, and snippets.

@ckhrysze
Last active April 7, 2016 02:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ckhrysze/015a8748910c8d467bd2a6e2c832a670 to your computer and use it in GitHub Desktop.
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
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