Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
PerlMonks performance issues....

by indigo (Scribe)
on Mar 16, 2001 at 23:24 UTC ( #64987=perlquestion: print w/replies, xml ) Need Help??

indigo has asked for the wisdom of the Perl Monks concerning the following question:

I am currently revising some HTML::Mason code. The original developer was not terribly familiar with, and wound up hand coding all the forms in raw HTML. This lead to really messy code and maintainability issues. I've made a pass through, and replaced all the form elements with calls.

The code is clean enough now, but it could be cleaner. In particular, the HTML leaves a something to be desired. I would like to go though and redo the table tags using, but I am concerned about performance.

I do not suspect 5 or 6 direct calls to the CGI form functions are going ot matter much. However, 40 calls through the autoloader to build a moderately complex table, that might be a little different.

Any wisdom on the performance of vs. straight HTML?

Replies are listed 'Best First'.
Re: performance issues....
by damian1301 (Curate) on Mar 17, 2001 at 01:27 UTC
    Putting in raw HTML is bound to be more errorful (if thats a word) for about 2 reasons I can think of.

    1. When you put raw HTML in print statements (excluding here documents and such) you have to backslash out the quotes and anyother characters that are illegal. It is much easier to just use CGI then go through hours of HTML checking for errors.

    2. CGI (the newer one) is W3 compatible or something like that. It follows the rules of W3. I dont know what else to put..

    BTW, I am back!

    Almost a Perl hacker.
    Dave AKA damian

    I encourage you to email me
Re: performance issues....
by merlyn (Sage) on Mar 17, 2001 at 00:12 UTC
Re: performance issues....
by knobunc (Pilgrim) on Mar 17, 2001 at 00:02 UTC
    It will be slower, but since you are using Mason anyway you are presumably using mod_perl. So the cost of loading the subroutines through the autoloader will only be paid the first time a given subprocess loads the module.

    You should probably load this module (any any other module you use a lot) in the mason_handler itself. In my handler I have:

    { package HTML::Mason::Commands; # Used by modules use Apache::DBI; use DBI; use DBD::Oracle; use CGI qw(-compile :all *table); }
    The braces are significant because they provide the appropriate scope for the package so the subroutines get imported into the correct namespace. You need to make sure that your package lines up with the one that mason will run your code in (HTML::Mason::Commands is the default so use that unless you overrode it in the Parser).

    The -compile argument to the 'use CGI' forces all subroutines to be loaded now rather than on their first usage so that they load into shared pages of the base apache process and the memory will be shared across all children. So you pay a little up front cost when starting the server, but subsequent uses are pretty fast and you save memory. What a deal

    So in short: make sure you are using mod_perl, preload the stuff and it will not cost much.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://64987]
Approved by root
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (4)
As of 2020-10-27 18:42 GMT
Find Nodes?
    Voting Booth?
    My favourite web site is:

    Results (257 votes). Check out past polls.