Created
November 9, 2011 20:57
-
-
Save bradland/1352997 to your computer and use it in GitHub Desktop.
Date bench
This file contains hidden or 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
#!/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 |
Tried today with Rubinius:
rubinius 2.0.0dev (1.8.7 95332ce8 yyyy-mm-dd JI) [x86_64-apple-darwin11.3.0]
user system total real
strptime 54.952456 0.181634 55.134090 ( 53.420454)
parse 34.012551 0.081722 34.094273 ( 33.583420)
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
My results with various versions of Ruby: