Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Exponential perf degradation in Time.parse #1319

Closed
headius opened this Issue · 0 comments

1 participant

Charles Oliver Nutter
Charles Oliver Nutter
Owner

This is the same basic issue as https://bugs.ruby-lang.org/issues/9221

On JRuby, it actually degrades a bit faster than on MRI 2.1. Here's the script:

require 'time'

def time_parse(s)
  puts "parsing #{s}"
  start = Time.now
  puts Time.parse(s)
  finish = Time.now
  puts "elapsed: #{finish - start}"
end

time_str = "12:00 PM "
40.times do |i|
  puts i
  time_parse(time_str)
  time_str << "f"
end

And here's the last few iterations I allowed to run:

parsing 12:00 PM fffffffffffffffffffffff
2013-12-10 12:00:00 +1000
elapsed: 0.453
24
parsing 12:00 PM ffffffffffffffffffffffff
2013-12-10 12:00:00 +1000
elapsed: 0.725
25
parsing 12:00 PM fffffffffffffffffffffffff
2013-12-10 12:00:00 +1000
elapsed: 1.163
26
parsing 12:00 PM ffffffffffffffffffffffffff
2013-12-10 12:00:00 +1000
elapsed: 1.957
27
parsing 12:00 PM fffffffffffffffffffffffffff
2013-12-10 12:00:00 +1000
elapsed: 3.086
28
parsing 12:00 PM ffffffffffffffffffffffffffff
2013-12-10 12:00:00 +1000
elapsed: 4.922
29

This likely affects all versions of JRuby using the new date/time logic, but I have not tested versions prior.

Charles Oliver Nutter headius modified the milestone: JRuby 9000, JRuby 1.7.10
Alex Tambellini atambo closed this in #1572
Philippe Weber wiibaa referenced this issue in elasticsearch/logstash
Open

Replace Time.parse with Time.iso8601 #1408

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.