Jean Boussier Profile picture
Oct 9 3 tweets 1 min read Read on X
@fractaledmind @_tomash I don't see any symbol related thing in your benchmark.

But yes the difference is pretty obvious. Your + version allocate two extra arrays per item to add.

The << only allocate when the array need to be resized (double every time so pretty good complexity).
@fractaledmind @_tomash > fastest and simplest way to merge two Arrays

Just use Array#concat
@fractaledmind @_tomash Also the benchmark title is a bit misleading, you are not doing `Array + Array` vs `Array << Entry`.

But `Array + [Entry]` vs `Array << Entry`.

• • •

Missing some Tweet in this thread? You can try to force a refresh
 

Keep Current with Jean Boussier

Jean Boussier Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @_byroot

Sep 4
Because @fxn doesn't stop at simple explanations, I went to dig into why this benchmark give the opposite results of what one would expect 🧵 Image
@fxn As Xavier rightfully pointed out in another thread, the second block is essentially hashing the hashcode a second time, so doing more work, you'd expect it to be slower. And yet, it's twice as fast.
@fxn What is happening is that Ruby hashes use a generic hash function called `rb_any_hash` that knows how to hash arbitrary objects.

Here `a` is the key that was passed (yeah C variable naming!). The second argument is a function pointer, kinda like a Ruby block if you will. Image
Read 21 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Don't want to be a Premium member but still want to support us?

Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal

Or Donate anonymously using crypto!

Ethereum

0xfe58350B80634f60Fa6Dc149a72b4DFbc17D341E copy

Bitcoin

3ATGMxNzCUFzxpMCHL5sWSt4DVtS8UqXpi copy

Thank you for your support!

Follow Us!

:(