• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 194
  • Last Modified:

Quick program size question

Just a quick question.  I have a perl script now that is ohhhh 50k and growing.  It might end up being in the 60s.  Will this slow the server down?  I have many features built right into this script (ie the search, etc.), would it be beneficial to say split the script up?  Make a seperate script for the search, one for the other stuff?

Pretty much what I'm asking is, will the server be bogged down if I have one HUGE script as opposed to a few smaller scripts.

1 Solution
It might.
It could also get bogged down fetching many small scripts.
Are you sure you need 50k lines to do this in perl?  That could be the equivalent of 500k lines of C code.
ingenitoAuthor Commented:
Well, the script doesn't only have a search, it has the following 'views' so to speak:

Search page 1
Search results
List Cuisines
List Restaurants in a certain cuisine
List Restaurants beginning with a certain letter
List Cities
List Restaurants in a certain city
List Info about a selected restaurant
List the restaurants menu

I could break up the code into a script for each, say:
One script for searchs, search.pl
One script for Cuisines, cuisine.pl
One for Alphabetical, alpha.pl

Would this be beneficial?

It's hard to judge without knowing more about the structure of your program.
I'd imagine many of those functions could share a lot of common code, and might make sense to go together.
(on the other hand, with 50k lines, thye may not me shareing much in common)
It might make sense to break it up based on different things the user can click on,
since each submit would be a different CGI invocation anyway.

Also, depending on what server you are running, you may be able to configure it to keep perl in core and not have to fork a new process eah time.
perldoc -q "How can I make my CGI script more efficient"
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

ingenitoAuthor Commented:

  I'm sorry, you misunderstood, there are not 50k lines, the file itself is 50k.  There are less than 1000 lines now.
Does this make it any better?
It still sounds large.  You can do a lot in 1000 50 character lines of Perl code.
But it's believable if most of that 50k is text.
ingenitoAuthor Commented:

It's a lot of HTML, what about my question though?
This is my first answer on the experts exchange so please forgive me if I make any mistakes.

Regarding your question. I’ll rephrase it a bit since you’re really asking more than one question.

Will a perl script CGI that is 60k run slower than a perl script CGI that is 5k assuming that the only difference between the two is code which is not being executed in the larger file (give or take a coupe of simple if statements) ?

The short answer is no.

Since the code being executed is the same in both files, the only difference is the time it will take to load the file into memory. With today’s hard disks there should be little difference in the absolute time it takes to load a 5k or 60k file.
Furthermore if you have enough memory (your web server does have enough memory right ?) and the file is accessed often then chances are that the file is in the servers cache so it won’t have to even read it from the disk.

None-the-less I would separate the files into smaller parts for other reasons. Readability. Being able to have different people edit different functions at the same time (version control) . Being able to quickly find the code you are looking for. Etc. You might have code that is used by many of your functions. I would put that code into a separate “inlude” file.

If you think that the script is not fast enough I would look at what ozo said :
>perldoc -q "How can I make my CGI script more efficient"

This will have a MUCH larger effect on the speed of your script (by orders of magnitude) then if it is 60k or 5k, though you might have to make some changes to the web server or perl script.


This question was awarded, but never cleared due to the JSP-500 errors of that time.  It was "stuck" against userID -1 versus the intended expert whom you awarded.  This corrects the problem and the expert will now receive these points; points verified.

Please click on your Member Profile and select "View Question History" to navigate through any open or locked questions you may have to update and finalize them.  If you are an EE Pro user, you can also choose Power Search to find all your open questions.

This is the Community Support link, if help is needed, along with the link to All Topics which reflects many TAs recently added.  Also in the Community Support link is a question on how experts can help, if they wish, on the cleaning of old and abandoned questions.

Thank you,
Moderator @ Experts Exchange
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now