Last active
December 3, 2015 11:12
-
-
Save gwilczynski/2bc2e2ab25b5f97eda12 to your computer and use it in GitHub Desktop.
Date parser
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 'date' | |
require 'benchmark' | |
def real_time | |
Benchmark.realtime do | |
100000.times do | |
yield | |
end | |
end | |
end | |
def print(time) | |
puts time.round(3) | |
end | |
date = '03-12-2015' | |
time = real_time { Date.parse(date) } | |
print(time) | |
time = real_time { Date.strptime(date, '%d-%m-%Y') } | |
print(time) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Results:
0.628
0.163