From: Michael Brooks Date: 2009-02-24T11:17:45+09:00 Subject: 1.9.1 regex 6.5 times slower than 1.8.6 in at least one case Hello: In general I've found Ruby 1.9.1 to be 2 times faster than 1.8.6 and roughly the same speed as Python 2.8 which is great... thanks guys, great job! However, in one case, when using a regular expressions (posted here by someone a long time ago) which I use to determine what numbers in 0..10000 are prime numbers, version 1.9.1 was at least 6.5 times slower (1.8.6 = 67 secs, 1.9.1 = 457 secs). The regular express is: ((("1" * self) =~ /^1$|^(11+?)\1+$/) == nil) which I've used in different versions of my program running either on its own or as part of an overloading function as follows: # Add an "is_prime?" method to the built-in numeric class # which returns true if the number is a prime number. class Fixnum def is_prime? ((("1" * self) =~ /^1$|^(11+?)\1+$/) == nil) end end I also have a version of the prime-number calculation program that which doesn't use the above regex (i.e. it uses a traditional brute force approach instead) and it runs 2 times faster in 1.9.1. In 1.9.1 the regex gets exponentially worse as the number being evaluated exceeding 1000. Does anyone know why the regex in 1.9.1 is so much slower than 1.8.6? Thank You, Michael