Created
December 15, 2014 22:55
-
-
Save jmdeldin/172f779a8a4bfd9bfafd to your computer and use it in GitHub Desktop.
ruby laziness
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/ips' | |
START = 1 | |
FINISH = 1_000_000 | |
HALF = FINISH / 2 | |
Benchmark.ips do |x| | |
x.report('lazy') do | |
(START..FINISH).lazy.include?(HALF) | |
end | |
x.report('nolazy') do | |
(START..FINISH).include?(HALF) | |
end | |
end | |
# -*- mode: ruby-compilation; default-directory: "~/src/sandbox/" -*- | |
# RubyComp started at Mon Dec 15 14:54:22 | |
# | |
# ruby /home/jmdeldin/src/sandbox/lazy.rb | |
# Calculating ------------------------------------- | |
# lazy 2.000 i/100ms | |
# nolazy 110.953k i/100ms | |
# ------------------------------------------------- | |
# lazy 48.681 (± 2.1%) i/s - 244.000 | |
# nolazy 4.018M (± 4.8%) i/s - 20.082M | |
# | |
# RubyComp finished at Mon Dec 15 14:54:36 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment