develooper Front page | perl.perl5.porters | Postings from June 2000

[ID 20000626.002] Slow s/// in 5.6 compared to 5.00403?

Thread Next
From:
Per Lindquist
Date:
June 26, 2000 08:22
Subject:
[ID 20000626.002] Slow s/// in 5.6 compared to 5.00403?
Message ID:
39577511.1E450032@dynamics.saab.se
This is a bug report for perl from per.lindquist@dynamics.saab.se,
generated with the help of perlbug 1.19 running under perl 5.006.


-----------------------------------------------------------------

Hi, I'm not sure if this should be called a bug but it's a problem
anyway.

I *have* tried to find out if this is reported/solved elsewhere, but
didn't succeed.

The 's///' statement seems to take a lot more time in version 5.6.0 than
in version 5.00403, at least in some cases. The execution time has
increased more than 20 times (an in-house script takes 20 minutes
instead of one, which is quite annoying).

A fairly pruned down (and perhaps a bit ugly?) example that at least
repeats the problem:

Search through a (long) file, find a certain parameter (near the end of
the file) and perform a replacement.

The problem occurs below the 'The interesting part' comment in the test
script.

The test file should be longer than showed in this mail in order to show
the problem more obviously. Replace the '...' line by say 300 or so
lines containing 'P MIDDLE = 0;' Save the file named 'testfile' in the
same directory as the test script.

Hope this is enough for you guys...

Regards, PerL (but still a perl rookie)

--- Test script start ---
#!/opt/local/sun4/bin/perl5.6.0 

sub read_file()
  {
    # Get the arguments:
    ($file_name) = @_;

    # Read the entire file into $file:
    open (FILE, "<$file_name") or 
      die ("Could not open $file_name for input");
    my $contents="";
    while (<FILE>) { $contents = $contents.$_; }
    close (FILE);

    return $contents;
  }

$file = &read_file("testfile");

for ($j=0; $j<=10; $j++)
  {
    # The interesting part:
    # Slow on 5.6, fast on 5.00403:
    if (!($file =~ s/(.*)LAST(.*=).*/$1LAST$2foo;/))
      {die("Could not patch file");} 
  }
#!/opt/local/sun4/bin/perl5.00403
#!/opt/local/sun4/bin/perl5.6.0 
--- Test script end ---

--- Test file start ---
P FIRST = 0;
P MIDDLE = 0;
P MIDDLE = 0;
...
P MIDDLE = 0;
P MIDDLE = 0;
P LAST = 0;
--- Test file end ---

[Please do not change anything below this line]
-----------------------------------------------------------------

---
Site configuration information for perl 5.006:

Configured by gnu at Fri May  5 13:06:38 MET DST 2000.

Summary of my perl5 (revision 5.0 version 6 subversion 0) configuration:
  Platform:
    osname=solaris, osvers=2.6, archname=sun4-solaris
    uname='sunos sol 5.6 generic_105181-11 sun4u sparc sun4u '
    config_args=''
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=undef use5005threads=undef useithreads=undef
usemultiplicity=undef
    useperlio=undef d_sfio=undef uselargefiles=define 
    use64bitint=undef use64bitall=undef uselongdouble=undef
usesocks=define
  Compiler:
    cc='cc', optimize='-O', gccversion=
    cppflags='-I/opt/gnu/include'
    ccflags ='-I/opt/gnu/include -D_LARGEFILE_SOURCE
-D_FILE_OFFSET_BITS=64'
    stdchar='unsigned char', d_stdstdio=define, usevfork=false
    intsize=4, longsize=4, ptrsize=4, doublesize=8
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
    ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t',
lseeksize=8
    alignbytes=8, usemymalloc=y, prototype=define
  Linker and Libraries:
    ld='cc', ldflags =' -L/opt/gnu/lib '
    libpth=/opt/gnu/lib /usr/lib /usr/ccs/lib
    libs=-lsocket -lnsl -ldl -lm -lc -lcrypt -lsec
    libc=/lib/libc.so, so=so, useshrplib=false, libperl=libperl.a
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags=' '
    cccdlflags='-KPIC', lddlflags='-G -L/opt/gnu/lib'


---
@INC for perl 5.006:
	/usr/local/slib/lib/perl5/5.6.0/sun4-solaris
	/usr/local/slib/lib/perl5/5.6.0
	/usr/local/slib/lib/perl5/site_perl/5.6.0/sun4-solaris
	/usr/local/slib/lib/perl5/site_perl/5.6.0
	/usr/local/slib/lib/perl5/site_perl
	.

---
Environment for perl 5.006:
    HOME=/home/perli
    LANG (unset)
    LC_COLLATE=sv
    LC_CTYPE=en_US
    LC_MESSAGES=C
    LC_MONETARY=en_US
    LC_NUMERIC=C
    LC_TIME=en_US
   
LD_LIBRARY_PATH=/opt/sql/oracle/lib:/opt/sql/pcms/dimensions5_0//lib/:/usr/lib:/opt/SUNWspro/SC4.0://opt/SUNWmotif/lib:/usr/openwin/lib:/usr/dt/lib:/usr/openwin/lib
    LOGDIR (unset)
   
PATH=/opt/sql/pcms/dimensions5_0//prog:/usr/5bin:/usr/openwin/bin:/usr/openwin/bin/xview:/usr/openwin/demo:.:/opt/local/bin:/opt/local/share/bin:/opt/local/slib/bin:/usr/ccs/bin:/opt/SUNWspro/bin:/usr/bin:/usr/ucb:/opt/Frame/5.5/bin:/cadre/tsa/com:/opt/Pure/Purify/purify-3.0-solaris2:/home/perli/bin:/home/vega/rld/eda/bin:/opt/MATLAB/bin://opt/SUNWmotif/bin:/opt/SUNWwabi/bin:/lkp/IRIS_T/arb/simmod/development/bin:/lkp/IRIS_T/arb/simmod/development/bin/sun:/opt/tools/sunbosim:/opt/sql/oracle/bin:/usr/sbin:/usr/dt/bin:/opt/Pure/Purecoverage/Current/:/opt/Pure/Quantify/Current:/opt/tools/bin:/opt/office/bin
    PERL_BADLANG (unset)
    SHELL=/usr/local/slib/bin/tcsh

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About