Perl5.8.0Total Elapsed Time = 0.080048 Seconds User+System Time = 0.080048 Seconds Exclusive Times %Time ExclSec CumulS #Calls sec/call Csec/c Name 87.4 0.070 0.070 40 0.0018 0.0018 main::extract 12.4 0.010 0.010 1 0.0100 0.0100 warnings::BEGIN 0.00 0.000 0.010 2 0.0000 0.0050 main::BEGIN 0.00 0.000 0.000 1 0.0000 0.0000 warnings::import 0.00 0.000 0.000 1 0.0000 0.0000 strict::import 0.00 0.000 0.000 1 0.0000 0.0000 strict::bits 0.00 0.000 0.000 1 0.0000 0.0000 Exporter::import 0.00 0.000 0.000 1 0.0000 0.0000 warnings::bits
Perl5.8.5Total Elapsed Time = 123.5199 Seconds User+System Time = 39.62993 Seconds Exclusive Times %Time ExclSec CumulS #Calls sec/call Csec/c Name 97.1 38.49 38.520 40 0.9622 0.9630 main::extract 0.05 0.020 0.020 1 0.0200 0.0200 utf8::SWASHNEW 0.03 0.010 0.010 1 0.0100 0.0100 utf8::AUTOLOAD 0.00 - -0.000 1 - - utf8::SWASHGET 0.00 - -0.000 1 - - Exporter::import 0.00 - -0.000 1 - - warnings::unimport 0.00 - -0.000 2 - - warnings::import 0.00 - -0.000 1 - - warnings::BEGIN 0.00 - -0.000 2 - - strict::unimport 0.00 - -0.000 4 - - strict::bits 0.00 - -0.000 2 - - strict::import 0.00 - -0.000 3 - - main::BEGIN 0.00 - -0.000 5 - - utf8::BEGIN
The main::extract subroutine takes about 9 times longer under Perl 5.8.5, and 549 times more under Perl 5.8.0, compared to Perl 5.6.1. The program itself took 1,543 times longer to finish under Perl 5.8.0 than it did under Perl 5.6.1. You may be wondering what the Perl program is:%Time ExclSec CumulS #Calls sec/call Csec/c Name 98.4 0.630 0.630 40 0.0157 0.0157 main::extract 1.56 0.010 0.010 1 0.0100 0.0100 warnings::BEGIN 0.00 - -0.000 1 - - warnings::import 0.00 - -0.000 1 - - strict::import 0.00 - -0.000 1 - - strict::bits 0.00 - 0.010 2 - 0.0050 main::BEGIN
As you can see, this code slurps a file and removes all occurences of a certain word (`whatever'). If you're wondering why Perl 5.8.0 took 2 minutes, it's not because I was using a larger file, and it's not because the file was large. The size of the file was exactly 11,221 (about ten thousand) bytes.use strict; use warnings; open (FILE, "a.txt"); my $text = ""; while (<FILE>) { $text .= $_; } close (FILE); while (my ($one, $two) = extract ($text)) { $text = $one . $two; } sub extract { my ($text) = @_; if ($text =~ /(.*?)whatever(.*)/is) { return ($1, $2); } return (); }
Perl 5.8.0%Time ExclSec CumulS #Calls sec/call Csec/c Name 88.1 0.670 0.670 1 0.6700 0.6700 main::extract
Perl 5.8.5%Time ExclSec CumulS #Calls sec/call Csec/c Name 95.0 2.490 2.510 1 2.4900 2.5100 main::extract
It's obvious that the little hat balanced out the differences between the three releases (although 3.7 times longer with Perl 5.8.0 is reason enough NOT to upgrade). Perl 5.8.5, in its current build was faster than Perl 5.6.1. The differences exist on account of different versions and different build parameters. To be more exact, here are the configuration summaries for the three releases:%Time ExclSec CumulS #Calls sec/call Csec/c Name 19.5 0.080 0.080 1 0.0800 0.0800 main::extract
Perl 5.8.0. Configuration Summaryusethreads=undef use5005threads=undef useithreads=undef usemultipl +icity=undef useperlio=undef d_sfio=undef uselargefiles=undef usesocks=undef use64bitint=undef use64bitall=undef uselongdouble=undef
Perl 5.8.5 Configuration Summaryusethreads=define use5005threads=undef useithreads=define usemulti +plicity=define useperlio= d_sfio=undef uselargefiles=define usesocks=undef use64bitint=undef use64bitall=undef uselongdouble=undef
The conclusion is that all regular expressions written like this:usethreads=undef use5005threads=undef useithreads=undef usemultipl +icity=undef useperlio=undef d_sfio=undef uselargefiles=undef usesocks=undef use64bitint=undef use64bitall=undef uselongdouble=undef
take a thousand times more on 5.8.0. The same expressions written as$text =~ /(.*?)<whatever>/
which obviously means the same thing (look for the first occurence of <whatever> and save the text preceding it in the corresponding variables) has the same performance implications across these two versions.$text =~ /^(.*?)<whatever>/
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: The Deceiver
by japhy (Canon) on Aug 13, 2004 at 13:16 UTC | |
by perldeveloper (Scribe) on Aug 13, 2004 at 14:04 UTC | |
by itub (Priest) on Aug 13, 2004 at 14:41 UTC | |
by perldeveloper (Scribe) on Aug 13, 2004 at 14:55 UTC | |
by tilly (Archbishop) on Aug 14, 2004 at 01:15 UTC | |
by itub (Priest) on Aug 13, 2004 at 15:12 UTC | |
| |
by japhy (Canon) on Aug 13, 2004 at 14:08 UTC | |
by Jenda (Abbot) on Aug 17, 2004 at 22:05 UTC | |
|
Re: The Deceiver
by diotalevi (Canon) on Aug 13, 2004 at 13:33 UTC | |
|
Re: The Deceiver
by perrin (Chancellor) on Aug 13, 2004 at 17:02 UTC | |
| |
|
Slapping People For Help
by chromatic (Archbishop) on Aug 13, 2004 at 17:29 UTC | |
by perldeveloper (Scribe) on Aug 13, 2004 at 19:21 UTC | |
by chromatic (Archbishop) on Aug 13, 2004 at 21:50 UTC | |
by PhilHibbs (Hermit) on Aug 16, 2004 at 17:19 UTC | |
by chromatic (Archbishop) on Aug 16, 2004 at 18:49 UTC | |
by Aristotle (Chancellor) on Aug 17, 2004 at 08:25 UTC | |
|
Re: The Deceiver
by TrekNoid (Pilgrim) on Aug 13, 2004 at 20:49 UTC | |
| |
|
Re: The Deceiver
by sleepingsquirrel (Chaplain) on Aug 13, 2004 at 15:10 UTC | |
by diotalevi (Canon) on Aug 13, 2004 at 15:20 UTC | |
by sleepingsquirrel (Chaplain) on Aug 13, 2004 at 15:52 UTC | |
by jryan (Vicar) on Aug 13, 2004 at 17:09 UTC | |
by perldeveloper (Scribe) on Aug 13, 2004 at 19:35 UTC | |
|
Re: The Deceiver
by jryan (Vicar) on Aug 13, 2004 at 19:08 UTC | |
| |
|
Re: Why does a Perl 5.6 regex run a lot slower on Perl 5.8?
by kscaldef (Pilgrim) on Aug 15, 2004 at 04:11 UTC | |
by perldeveloper (Scribe) on Aug 15, 2004 at 13:51 UTC |