Created
November 28, 2011 08:21
-
-
Save seban/1399594 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'benchmark' | |
Benchmark.bm(7) do |x| | |
x.report("length") { 10.times { Array.new(10_000, 1).length > 0 } } | |
x.report("any?") { 10.times { Array.new(10_000, 1).any? } } | |
end | |
array = Array.new(10_000, 1) | |
Benchmark.bm(7) do |x| | |
x.report("length") { 100.times { array.length > 0 } } | |
x.report("any?") { 100.times { array.any? } } | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment