Created
November 9, 2011 20:57
-
-
Save bradland/1352997 to your computer and use it in GitHub Desktop.
Date bench
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
#!/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 |
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
Tried today with Rubinius: