From: Ruby Newbee Date: 2010-01-04T17:54:14+09:00 Subject: Is ruby's regex slower? Hi, I wrote this message without other purpose, just show a result for comparison. :-) First I got the page which will be used for analysis (got all domain names from it): wget http://www.265.com/Kexue_Jishu/ It will get an index.html page. Then I run this ruby script: #!/usr/bin/ruby f = File.open("index.html") f.each_line do |c| puts $1 if /href="http:\/\/(.*?)\/.*" target="_blank"/ =~ c end f.close And this perl script: #!/usr/bin/perl open HD,"index.html" or die $!; while() { print $1,"\n" if /href="http:\/\/(.*?)\/.*" target="_blank"/; } close HD; When using "time" command to see the running time, I saw ruby is slower than perl (maybe due to the regex?). Ruby's: real 0m0.013s user 0m0.012s sys 0m0.000s Perl's: real 0m0.004s user 0m0.004s sys 0m0.000s Both versions: # ruby -v ruby 1.9.1p243 (2009-07-16 revision 24175) [i686-linux] # perl -v This is perl, v5.8.8 built for i486-linux-thread-multi Yes that's the result, but not influence me to love ruby. Thanks. Jenn.