Closed jmettraux closed 4 years ago
Focus on the critical piece.
require 'benchmark'
require 'chronic'
require 'fugit'
# https://github.com/ondrejbartas/sidekiq-cron/issues/276
crons = nil
puts Benchmark.measure {
crons = ([ '0 8 1 * * America/Chicago' ] * 1000)
.collect { |c| Fugit.parse(c) }
}
time = Time.now
#EtOrbi.chronic_enabled = false
puts Benchmark.measure {
crons.map { |cron| cron.previous_time(time) }
}.to_s
# bad =>
# 0.760012 0.004290 0.764302 ( 0.764780)
# 110.418065 0.677115 111.095180 (111.298025)
As seen in https://github.com/ondrejbartas/sidekiq-cron/issues/276
Fugit::Cron#previous_time
ends up calling https://github.com/floraison/et-orbi/blob/master/lib/et-orbi/make.rb#L106-L112 so the incomingTime
instances ends up as a String and that's where Chronic is called. Do avoid that!