Link to home
Start Free TrialLog in
Avatar of saskia
saskia

asked on

What is faster ?

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.
Avatar of maneshr
maneshr

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.
ASKER CERTIFIED SOLUTION
Avatar of jhurst
jhurst

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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 ...
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.

jhurst, most web-servers are able to run their OS binary executables, no matter in what lang they was written, before compiling !
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.
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 ...
Avatar of saskia

ASKER

Thanks for helping me out !!!