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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Aaaand one with JRuby: