Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


Quick program size question

Posted on 1999-06-23
Medium Priority
Last Modified: 2013-12-25
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.

Question by:ingenito
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 84

Expert Comment

ID: 1834724
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.

Author Comment

ID: 1834725
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,
One script for Cuisines,
One for Alphabetical,

Would this be beneficial?

LVL 84

Expert Comment

ID: 1834726
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"
Certified OpenStack Administrator Course

We just refreshed our COA course based on the Newton exam.  With 14 labs, this course goes over the different OpenStack services that are part of the certification: Dashboard, Identity Service, Image Service, Networking, Compute, Object Storage, Block Storage, and Orchestration.


Author Comment

ID: 1834727

  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?
LVL 84

Expert Comment

ID: 1834728
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.

Author Comment

ID: 1834729

It's a lot of HTML, what about my question though?

Accepted Solution

pru2 earned 1760 total points
ID: 1834730
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.


Expert Comment

ID: 6873889

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

Featured Post

Linux Academy Android App Now Supports Chromecast

We have some fantastic news for our Android fans. We’re so excited to announce that the Linux Academy Android app is now available with Chromecast support. That’s right – simply download the latest update of the Linux Academy App and start casting your favorite course videos!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you get a (Blue Screen of Death), your system writes a small file called a minidump. Your first step is to make certain your computer is setup to record memory dumps. Right click My Computer, choose properties. Click on the advanced tab, an…
In this tutorial I will show you how to provide a dynamic RTF document on your website generated with data from your database. For this tutorial you will need Microsoft Word or WordPad, WhizBase and Microsoft Access. In this tutorial I will show …
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question