holidays/test/benchmark.rb

45 lines
634 B
Ruby
Raw Normal View History

2007-11-20 01:58:20 +01:00
require File.dirname(__FILE__) + '/test_helper'
require 'date'
2007-11-24 01:45:30 +01:00
require 'holidays'
require 'holidays/ca'
2007-11-20 01:58:20 +01:00
require 'benchmark'
2007-11-24 01:45:30 +01:00
2007-11-20 01:58:20 +01:00
n = 10000
2007-11-24 01:45:30 +01:00
dt = Date.civil(2035,3,23)
2007-11-20 01:58:20 +01:00
Benchmark.bm do |x|
2007-11-24 01:45:30 +01:00
x.report('0001') do
1.times do
r = Holidays.on(dt, :any)
end
end
x.report('0010') do
10.times do
r = Holidays.on(dt, :any)
end
end
x.report('0100') do
100.times do
r = Holidays.on(dt, :any)
2007-11-20 01:58:20 +01:00
end
end
2007-11-24 01:45:30 +01:00
x.report('1000') do
1000.times do
r = Holidays.on(dt, :any)
2007-11-20 01:58:20 +01:00
end
end
2007-11-24 01:45:30 +01:00
x.report('5000') do
5000.times do
r = Holidays.on(dt, :any)
end
end
2007-11-20 01:58:20 +01:00
end