Bug #12453
closed2.3.1p112 version running demo of array methods about 3x slower than running it with 2.2.0p0 version
Description
The 2.3.1p112 version ran a script that had a very simple demo of array methods close to 3x slower than running it with 2.2.0p0 version. My test environment is Ubuntu 14.04.
Steps to replicate:
- Add the following code to example.rb:
#!/usr/bin/env ruby2 require 'set' def display_names name_list puts '****************************' name_list.each do |name| puts name end puts "\n" end names = ['Bob', 'Jack', 'Jill', 'Mike', 'John', 'Jim', 'Lisa'] name_list = [] names.each do |name| name_list.push name end display_names name_list more_names = ['Mark', 'Matt', 'Luke', 'Juan', 'Jose'] name_list.concat more_names display_names name_list puts 'Put Alfa at the front of the line ...' name_list.insert 0, 'Alfa' display_names name_list puts 'Remove Bob from the list ...' name_list.delete 'Bob' display_names name_list puts 'Remove the first and last ...' name_list.delete_at 0 name_list.pop display_names name_list puts 'Clear the whole list ...' name_list.clear display_names name_list puts 'Fill it with names again ...' name_list = Array.new names display_names name_list puts 'Get the index of "Mike" ...' puts name_list.index 'Mike' puts 'Get the count of "Mike" in name_list ...' puts name_list.count 'Mike' puts 'Sort name_list by alphabetical order ...' name_list.sort display_names name_list puts "Now let's reverse them ..." name_list.reverse display_names name_list puts 'Slice the 2nd through 4th values ...' display_names name_list.slice 1, 4 puts 'Inserting Charles at the 3rd position ...' name_list.insert 2, 'Charles' display_names name_list puts 'Now removing Charles ...' name_list.delete_at 2 display_names name_list puts "Let's switch to numbers ..." num_list = [5, 7, 9, 2, 4, 6] display_names num_list puts "Let's double them ..." doubles = num_list.map{|i| i * 2} display_names doubles puts "Ok, now to sets ..." fruits = Set.new ['banana', 'orange', 'apple', 'apple', 'grapes'] display_names fruits - Run using these versions:
ruby 2.2.0p0 (2014-12-25 revision 49005) [x86_64-linux]
ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-linux]
OBSERVED BEHAVIOR:
- My times when I run 2.2.0p0:
real 0m0.071s
user 0m0.064s
sys 0m0.004s
- My times when I run 2.3.1p112:
real 0m0.191s
user 0m0.093s
sys 0m0.107s
EXPECTED BEHAVIOR:
My expectations are that Ruby with the newer version should be getting faster rather than slower.
Files
Updated by noahgibbs (Noah Gibbs) over 9 years ago
For me on a Retina MacBook w/ OS X 10.11.5, using ruby_2_2 branch from Git mirror:
real 0m0.043s
user 0m0.029s
sys 0m0.008s
Using current master:
real 0m0.037s
user 0m0.028s
sys 0m0.007s
The numbers for current head are identical or slightly better.
Perhaps the bug is Ubuntu-specific?
Updated by HarlinSeritt (Harlin Seritt) over 9 years ago
Noah Gibbs wrote:
For me on a Retina MacBook w/ OS X 10.11.5, using ruby_2_2 branch from Git mirror:
real 0m0.043s
user 0m0.029s
sys 0m0.008sUsing current master:
real 0m0.037s
user 0m0.028s
sys 0m0.007sThe numbers for current head are identical or slightly better.
Perhaps the bug is Ubuntu-specific?
Thanks, Noah ... I'll test the on a couple of other Linux distros.
Updated by hsbt (Hiroshi SHIBATA) over 9 years ago
- Status changed from Open to Feedback
Updated by jeremyevans0 (Jeremy Evans) about 6 years ago
- Status changed from Feedback to Closed