Skip to content

Instantly share code, notes, and snippets.

@gwilczynski
Last active December 3, 2015 11:12
Show Gist options
  • Save gwilczynski/2bc2e2ab25b5f97eda12 to your computer and use it in GitHub Desktop.
Save gwilczynski/2bc2e2ab25b5f97eda12 to your computer and use it in GitHub Desktop.
Date parser
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)
@gwilczynski
Copy link
Author

Results:
0.628
0.163

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment