CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Advanced:
Slow module problem?

 



lichtjiang
New User

Aug 4, 2007, 10:43 AM

Post #1 of 2 (755 views)
Slow module problem? Can't Post

I have a class moduel A.pm, a non-class module B.pm and a console file C.pl.

This is relationship of 3 files:

C.pl "use B;"
B.pm "use A;" and "new A();"

In "new" of A.pm, I have some codes to read a file for about 240000 lines.

But it took extremely long time ( more than 5 minutes!) for A to finish reading those 240000 lines in "new".

I tested to just "new A()" from command line and from a simple perl file that only does this. It finishes in a second.

I'm confused and perl -d didn't help to tell why it takes long time. perl -d:DProf and dprofpp did show that the "new" subroutine takes long time and it also shows: "Exporter::as_heavy" and "DynaLoader::BEGIN"(which I didn't explicitly call in my program at all).

Any thoughts?

Thanks!


lichtjiang
New User

Aug 4, 2007, 2:08 PM

Post #2 of 2 (752 views)
Re: [lichtjiang] Slow module problem? [In reply to] Can't Post

Solved finally.

In the while loop (in "new" of "A.pm"), I used regular expression to look for certain patterns. Unfortunately, in "B.pm", "English" module is used and that was included long time ago for test purpose (yes, unfortunately, it is still there, BADMad) and I didn't notice it twice for this problem. Now, I check all modules used to locate where the problem is and realized that it caused this performance problem.

This is a reminder to anyone who happens to use this module "English", from its documentation:

PERFORMANCE ^

This module can provoke sizeable inefficiencies for regular expressions, due to unfortunate implementation details. If performance matters in your application and you don't need $PREMATCH, $MATCH, or $POSTMATCH, try doing

use English qw( -no_match_vars ) ;

. It is especially important to do this in modules to avoid penalizing all applications which use them.

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives