benchmark.rb in timeliness-0.4.3 vs benchmark.rb in timeliness-0.4.4
- old
+ new
@@ -11,20 +11,20 @@
Timeliness::Parser.parse("2000-01-04 12:12:12", :datetime)
end
end
n = 10_000
-Benchmark.bm do |x|
+Benchmark.bm(40) do |x|
x.report('timeliness - datetime') {
n.times do
Timeliness::Parser.parse("2000-01-04 12:12:12", :datetime)
end
}
x.report('timeliness - datetime with :format') {
n.times do
- Timeliness::Parser.parse("2000-01-04 12:12:12", :datetime, :format => 'yyyy-mm-dd hh:nn:ss')
+ Timeliness::Parser.parse("2000-01-04 12:12:12", :datetime, format: 'yyyy-mm-dd hh:nn:ss')
end
}
x.report('timeliness - date') {
n.times do
@@ -128,25 +128,9 @@
n.times do
hash = Date._parse("2000-01-32 12:12:12")
Time.mktime(hash[:year], hash[:mon], hash[:mday], hash[:hour], hash[:min], hash[:sex]) rescue nil
end
}
-
- if defined?(ParseDate)
- x.report('parsedate - valid') {
- n.times do
- arr = ParseDate.parsedate("2000-01-04 12:12:12")
- Date.new(*arr[0..2])
- Time.mktime(*arr)
- end
- }
-
- x.report('parsedate - invalid ') {
- n.times do
- arr = ParseDate.parsedate("2000-00-04 12:12:12")
- end
- }
- end
x.report('strptime - valid') {
n.times do
DateTime.strptime("2000-01-04 12:12:12", '%Y-%m-%d %H:%M:%s')
end