Created
February 27, 2009 18:34
-
-
Save jwreagor/71626 to your computer and use it in GitHub Desktop.
This file contains hidden or 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("#any?") { (0...1_000_000_000_000).any? {|n| break true if n > 999_999} } | |
x.report("#map") { (0...1_000_000_000_000).map {|n| break true if n > 999_999}.is_a?(TrueClass) } | |
x.report("#each") { (0...1_000_000_000_000).each {|n| break true if n > 999_999} } | |
end | |
user system total real | |
#any? 9.210000 3.300000 12.510000 ( 12.554455) | |
#map 9.290000 3.320000 12.610000 ( 12.672998) | |
#each 7.240000 2.470000 9.710000 ( 9.746388) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment