Skip to content

Instantly share code, notes, and snippets.

@headius
Created January 12, 2012 21:26
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save headius/1603227 to your computer and use it in GitHub Desktop.
Save headius/1603227 to your computer and use it in GitHub Desktop.
require 'benchmark'
require 'time'
string = "2010-11-10 23:00:00 UTC"
n = 100_000
(ARGV[0] || 5).to_i.times do
Benchmark.bm(20) do |b|
b.report 'Time.parse' do
n.times do
Time.parse(string)
end
end
b.report 'Time.strptime' do
format = '%Y-%m-%d %H:%M:%S %z'
n.times do
Time.strptime(string, format)
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment