Created
December 30, 2015 23:45
-
-
Save wildjcrt/7e58ea08fa3836480c31 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/ips' | |
require 'date' | |
Benchmark.ips do |x| | |
x.time = 100 | |
x.report('Time') do | |
Time.now.year | |
end | |
x.report('Date') do | |
Date.today.year | |
end | |
x.compare! | |
end |
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
alculating ------------------------------------- | |
Time 46.022k i/100ms | |
Date 47.454k i/100ms | |
------------------------------------------------- | |
Time 706.802k (±15.4%) i/s - 67.192M | |
Date 756.214k (±12.6%) i/s - 73.506M | |
Comparison: | |
Date: 756214.0 i/s | |
Time: 706801.8 i/s - 1.07x slower |
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
time: 5 | |
*** | |
Calculating ------------------------------------- | |
Time 52.173k i/100ms | |
Date 51.742k i/100ms | |
------------------------------------------------- | |
Time 759.292k (±11.6%) i/s - 3.756M | |
Date 777.805k (±10.3%) i/s - 3.881M | |
Comparison: | |
Date: 777804.6 i/s | |
Time: 759291.9 i/s - 1.02x slower |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
$ ruby -v # => ruby 2.2.3p173 (2015-08-18 revision 51636) [x86_64-darwin15]