From: the.codefolio.guy@... Date: 2016-06-06T23:01:32+00:00 Subject: [ruby-core:75867] [Ruby trunk Bug#12453] 2.3.1p112 version running demo of array methods about 3x slower than running it with 2.2.0p0 version Issue #12453 has been updated by Noah Gibbs. 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? ---------------------------------------- Bug #12453: 2.3.1p112 version running demo of array methods about 3x slower than running it with 2.2.0p0 version https://bugs.ruby-lang.org/issues/12453#change-59039 * Author: Harlin Seritt * Status: Open * Priority: Normal * Assignee: * ruby -v: * Backport: 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN ---------------------------------------- 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: 1. 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 ~~~ 2. 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: 3. My times when I run 2.2.0p0: real 0m0.071s user 0m0.064s sys 0m0.004s 4. 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-------------------------------- example5.rb (1.77 KB) -- https://bugs.ruby-lang.org/ Unsubscribe: