Skip to content

Commit

Permalink
Remove overhead of surrounding block from length-vs-size-vs-count ben…
Browse files Browse the repository at this point in the history
…chmark.

See fastruby#96 for detailed explanation
  • Loading branch information
radarek committed Jan 25, 2016
1 parent ca29eed commit 5f943ce
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions code/array/length-vs-size-vs-count.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
require 'benchmark/ips'

ARRAY = [*1..100]
$array = [*1..100]

Benchmark.ips do |x|
x.report("Array#length") { ARRAY.length }
x.report("Array#size") { ARRAY.size }
x.report("Array#count") { ARRAY.count }
x.report("Array#length", "$array.length;" * 1_000)
x.report("Array#size", "$array.size;" * 1_000)
x.report("Array#count", "$array.count;" * 1_000)
x.compare!
end

0 comments on commit 5f943ce

Please sign in to comment.