Skip to content

Instantly share code, notes, and snippets.

@bradland
Created November 9, 2011 20:57
Show Gist options
  • Save bradland/1352997 to your computer and use it in GitHub Desktop.
Save bradland/1352997 to your computer and use it in GitHub Desktop.
Date bench
#!/usr/bin/env ruby
require 'benchmark'
require 'date'
Benchmark.bm do|b|
ITERATE = 100000
b.report("strptime") do
time = "2011-05-25 00:00:03 -0400"
fmt = "%Y-%m-%d %H:%M:%S %z"
ITERATE.times { DateTime.strptime(time, fmt) }
end
b.report("parse") do
time = "2011-05-25 00:00:03 -0400"
ITERATE.times { DateTime.parse(time) }
end
end
@bradland
Copy link
Author

Aaaand one with JRuby:

jruby 1.6.6 (ruby-1.8.7-p357) (2012-01-30 5673572) (Java HotSpot(TM) 64-Bit Server VM 1.6.0_29) [darwin-x86_64-java]
              user     system      total        real
strptime 22.628000   0.000000  22.628000 ( 22.589000)
parse    15.086000   0.000000  15.086000 ( 15.086000)

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