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

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

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


New User

Aug 4, 2007, 10:43 AM

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

I have a class moduel, a non-class module and a console file

This is relationship of 3 files: "use B;" "use A;" and "new A();"

In "new" of, 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?


New User

Aug 4, 2007, 2:08 PM

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

Solved finally.

In the while loop (in "new" of ""), I used regular expression to look for certain patterns. Unfortunately, in "", "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:


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