Last active
September 23, 2016 05:46
-
-
Save cpappen/1b0f04d339fb2ba8eea1be5b3ad787f2 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' | |
n = 500_000 | |
GIGA_SECOND = 10**9 | |
time = Time.utc(2011, 4, 25, 0, 0, 0) | |
Benchmark.bm do |x| | |
x.report("with CONST") { for i in 1..n; time + GIGA_SECOND; end } | |
x.report("no CONST") { for i in 1..n; time + 10**9; end } | |
x.report("no CONST") { for i in 1..n; time+= 10**9; end } | |
x.report("with CONST") { for i in 1..n; time+= GIGA_SECOND; end } | |
end | |
# user system total real | |
# with CONST 0.130000 0.000000 0.130000 ( 0.127017) | |
# no CONST 0.180000 0.000000 0.180000 ( 0.179682) | |
# no CONST 0.140000 0.000000 0.140000 ( 0.149598) | |
# with CONST 0.140000 0.000000 0.140000 ( 0.132537) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment