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

x
?
Solved

What is faster ?

Posted on 2000-03-06
8
Medium Priority
?
151 Views
Last Modified: 2013-12-25
I've got a relative big script (60 kb)that has many sub's. Now I'm wandering if the script can be handled of quicker if I:
- make seperate files of the subs, with an 'require' sentence that points to the variables

- make seperate files of the subs, and each of them has got the same variables (as in the large script right now) in them.

- keep the large script.
0
Comment
Question by:saskia
[X]
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
8 Comments
 
LVL 16

Expert Comment

by:maneshr
ID: 2589455
personally i dont any of the approaches will speed up your script (even though it apprears to be a big one),
what you might want to do is optmize the sub routine themselves & make them more generalized.
0
 
LVL 8

Accepted Solution

by:
jhurst earned 200 total points
ID: 2589591
I largely agree with maneshr - optimizing the code is the main thing to do.

However, most web servers are not very good at finding and opening files, especially if they are on a network so you will tend to find that a script with less extra files will work faster.

I actually had a script on a SunOS server that needed to open about 30 files and do something with them.  I pre-saved the 30 files in one big one and the script typically ran in less than half the time.  

I then tried the same thing with perl modules and found the same problem.  If I need a module for just one small thing I copy the code into my main script.  Even though this is inellagant - it is faster.

Now, the real question is, "does this loss of ellegance pay off in terms of perceived performance improvement?"  - usually NO!
0
 
LVL 1

Expert Comment

by:ercis
ID: 2590091
saskia, you can make your script run quicker, with porting it to quicker language, i.e. PHP or C. And try to optimize your code ...
0
Monthly Recap

May was a big month for new releases from Linux Academy! Take a look at what our team built recently in our blog. You can access the newest releases from our blog.

 
LVL 8

Expert Comment

by:jhurst
ID: 2590107
To some degree the script may run faster in C or something rather than perl - however, realistically it is a rare script that does enough for this to make a difference.  And, many servers are optimized for perl at this time while they are not for C.  Especially if you take into account that moost C programs end up being huge to load and most web-servers are intelligent enough to share the perl interpretter.

0
 
LVL 1

Expert Comment

by:ercis
ID: 2590222
jhurst, most web-servers are able to run their OS binary executables, no matter in what lang they was written, before compiling !
0
 
LVL 8

Expert Comment

by:jhurst
ID: 2592982
ercis, I agree.  And in fact this is really the problem with perl, that the code is sort of compiled when it is just about to be executed, and this does take some additional time.  In fact, for many this is the motivation for the perl->exe type products so that they can make executables ahead of time.

The problem with these perl->binary conversions is that like C, they make large files which tend to be slow to load.  However, there is no question that there may be times when the extra load time is warranted by the saving in the pre-compilation.

Having said all of this.  I doubt that it will be detactable.  Whereas, grabbing a large number of include and require modules can be detectable.
0
 
LVL 1

Expert Comment

by:ercis
ID: 2594332
hmm imho, time to load one binary = time to run Perl interpreter, hence Perl needs +more time to interpret and execute script itself.
about size, usually binary execeutable file size is similar to corresponding C code (under Linux). so, "little" script (~15kB) can do big job ...
0
 

Author Comment

by:saskia
ID: 2601750
Thanks for helping me out !!!
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

It is a general practice to get rid of old user profiles on a computer  in a LAN environment. As I have been working with a company in a LAN environment where users move from one place to some other place at times. This will make many user profil…
This article will show, step by step, how to integrate R code into a R Sweave document
Learn the basics of while and for loops in Python.  while loops are used for testing while, or until, a condition is met: The structure of a while loop is as follows:     while <condition>:         do something         repeate: The break statement m…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

688 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