fastruby / fast-ruby

:dash: Writing Fast Ruby :heart_eyes: -- Collect Common Ruby idioms.
https://github.com/fastruby/fast-ruby
5.67k stars 376 forks source link

Remove overhead of surrounding block from length-vs-size-vs-count benchmark #97

Closed radarek closed 1 year ago

radarek commented 8 years ago

See #96 for detailed explanation

Before:

ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-darwin15]
Calculating -------------------------------------
        Array#length   135.292k i/100ms
          Array#size   137.775k i/100ms
         Array#count   132.586k i/100ms
-------------------------------------------------
        Array#length      9.906M (± 7.6%) i/s -     49.246M
          Array#size     10.038M (± 6.0%) i/s -     50.012M
         Array#count      8.399M (± 6.0%) i/s -     41.897M

Comparison:
          Array#size: 10038186.0 i/s
        Array#length:  9905809.3 i/s - 1.01x slower
         Array#count:  8399076.6 i/s - 1.20x slower

After:

ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-darwin15]
Calculating -------------------------------------
        Array#length    10.290k i/100ms
          Array#size    10.301k i/100ms
         Array#count     3.649k i/100ms
-------------------------------------------------
        Array#length    111.847k (± 2.0%) i/s -    565.950k
          Array#size    112.374k (± 2.0%) i/s -    566.555k
         Array#count     37.865k (± 2.1%) i/s -    189.748k

Comparison:
          Array#size:   112373.6 i/s
        Array#length:   111847.4 i/s - 1.00x slower
         Array#count:    37865.1 i/s - 2.97x slower
nateberkopec commented 8 years ago

:+1: We should probably write something down, maybe in Contributing.md, about preferring this style where possible.

benoittgt commented 7 years ago

What is the status of this PR? I can work on that.

etagwerker commented 1 year ago

@benoittgt I believe no one has worked on this for years. Feel free to take a stab at it. 👍🏼

etagwerker commented 1 year ago

Closing this because it has had no activity in years. Feel free to re-open if you get to time to address the comments. Thanks!