Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Minor
-
Resolution: Not A Bug
-
Affects Version/s: JRuby 1.1.1
-
Fix Version/s: None
-
Component/s: Performance
-
Labels:None
-
Environment:ruby 1.8.5 (2007-11-25 rev 4842) [i386-jruby1.1b1], OS X 10.4.11
-
Number of attachments :
Description
Like MRI, JRuby's Array#insert method becomes very slow with high numbers of iterations. Below is a snippet, which is also included as part of the bench_array.rb program in ruby_test:
require "benchmark"
MAX = 200000
Benchmark.bm(35) do |x|
x.report("Array#insert"){
array = [1,2,3,4]
MAX.times{ array.insert(2, "a", "b") }
}
end
Yeah, we need a bit different approach than MRI takes here, there's still room for improvement in Array (especially for this case). But remember, we don't have realloc in java.