Skip to content

Instantly share code, notes, and snippets.

@ismaelga
Last active June 14, 2016 18:09
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 ismaelga/36992b2150421307743a47113042afcf to your computer and use it in GitHub Desktop.
Save ismaelga/36992b2150421307743a47113042afcf to your computer and use it in GitHub Desktop.
defmodule AppendBench do
use Benchfella
@list Enum.into 1..10000, []
bench "++" do
h = Enum.at @list, 0
@list ++ [h]
end
bench "List.insert_at" do
h = Enum.at @list, 0
List.insert_at @list, -1, h
end
end
@ismaelga
Copy link
Author

Settings:
duration: 1.0 s

AppendBench

[19:01:09] 1/2: List.insert_at
[19:01:12] 2/2: ++

Finished in 7.31 seconds

AppendBench

++ 50000 64.73 µs/op
List.insert_at 10000 298.41 µs/op

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment