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

Optimized version of Tuple#to_a #8265

Merged
merged 1 commit into from
Oct 3, 2019
Merged

Conversation

asterite
Copy link
Member

@asterite asterite commented Oct 3, 2019

Benchmark:

require "benchmark"

Benchmark.ips do |x|
  x.report("old") do
    {1, 2, 3, 4}.to_a
  end
  x.report("new") do
    {1, 2, 3, 4}.to_a2
  end
end

Results:

old  24.58M ( 40.68ns) (± 2.92%)  64.0B/op   1.42× slower
new  34.95M ( 28.62ns) (± 2.73%)  64.0B/op        fastest

It's not much but it's something.

@asterite asterite added this to the 0.32.0 milestone Oct 3, 2019
@asterite asterite merged commit 7a1112c into crystal-lang:master Oct 3, 2019
@asterite asterite deleted the tuple-to_a branch October 3, 2019 13:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants