How long is too long for cgi script?

E

el_roachmeister

What is the ballpark limit for the size of a script before the perl
interpreter takes more than a few seconds to load it? I have a cgi
script that is not CPU or memory intensive but is around a few thousand
lines of code and uses a few modules. It runs in less than a second.

Customers keep requesting new features and I am hesitant to just
blindly growing the code. What is the point where the code will take
too long to load into the interpreter (>3 seconds)? Can I juse use
modules wiley-niley or do I have to count the lines of code in them
too?

And what if the code does become too large ? Is there anything I can do
to speed it up?

Thanks!
 
X

xhoster

What is the ballpark limit for the size of a script before the perl
interpreter takes more than a few seconds to load it? I have a cgi
script that is not CPU or memory intensive but is around a few thousand
lines of code and uses a few modules. It runs in less than a second.

Customers keep requesting new features and I am hesitant to just
blindly growing the code. What is the point where the code will take
too long to load into the interpreter (>3 seconds)?

The time necessary to compile depends on the content of the lines, not
just the number of them.


[linux]$ perl - > x.pl
print <<'END';
use strict;
exit;
END
my $size=100_000;
foreach my $x (1..$size) {
print "sub foo$x { return ", rand(), "};\n";
};
__END__

now do:
[linux]$ time perl -c x.pl
x.pl syntax OK
1.820u 0.120s 0:01.93 100.5% 0+0k 0+0io 343pf+0w

So it look less than 2 seconds to compile 100_000 lines of sub
definitions.

On the other hand, compiling a script that consisted of for loops
nested 10_000 deep took 3.5 seconds.

Can I juse use
modules wiley-niley or do I have to count the lines of code in them
too?

Counting lines is pointless. If you want to know how long it takes to
compile, measure how long it takes to compile.
And what if the code does become too large ? Is there anything I can do
to speed it up?

You could use mod_perl. Or you could break the CGI app into different
task-oriented scripts, each which has just the code necessary to address
that task.

Xho
 
D

David K. Wall

What is the ballpark limit for the size of a script before the
perl interpreter takes more than a few seconds to load it?

It's too big when it's too slow. :)

I have one recent program that took 15 or more minutes to run on a
fairly fast machine, but considering that it would take me weeks to do
the same (boring, repetitive) work "by hand", it's fast enough.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top