Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update bench #1

Merged
merged 1 commit into from
Nov 25, 2016
Merged

update bench #1

merged 1 commit into from
Nov 25, 2016

Conversation

zhongwencool
Copy link
Contributor

Update:

  1. Using list_to_binary/1 replace io:iodata_to_binary/1, because we already known it's a list.
  2. Update << random, acc::binary>> replace << acc::binary, random>>, make sure benchmark more fair.

Great to know!!
[item|list] is faster than <<item, list/binary>>
But binary construction is more flexible then list construction
we can do

item = 100,
list = <<1,2,,3,4,5,6>>
<<Item, list/binary>> # add item at head
or 
<<list/binary, item>> # add item at tail

if it a list, we only can do

[item|list] # add item at head, can't add it to tail.

@secretworry
Copy link
Owner

Cool, Being more flexible has its downside too, I guess.

@secretworry
Copy link
Owner

Extending a binary involves malloc&copy, while prepending a list would just incur assigning a pointer, I think that's the reason

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants