Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

Testing Efficiency

by Jonas (Beadle)
on Aug 29, 2000 at 08:24 UTC ( #30075=perlquestion: print w/replies, xml ) Need Help??

Jonas has asked for the wisdom of the Perl Monks concerning the following question:

Hey folks,

I'm building and testing a bunch of scripts on my box at home. I'm eventually going to upload them to a hosting service. For the sake of speed and effeciency, I'm wanting to know how much my scripts are taxing the system (e.g. Processing time, Memory Usage, Execution Time, etc). What command(s) do I use to perform these diagnostics, so that I can work to make my scripts better?

Thanks in advance,

Replies are listed 'Best First'.
(Ovid) Re: Testing Efficiency
by Ovid (Cardinal) on Aug 29, 2000 at 10:57 UTC
    Perhaps one of the most important things you can do is use benchmark. This can give you an excellent method of comparing how efficient different methods of approaching the same problem are. Examples: Learn to live by this module and you will begin to understand things about Perl efficiency that most of us only dream of.


Re: Testing Efficiency
by athomason (Curate) on Aug 29, 2000 at 08:37 UTC
    It partly depends on what your script is doing: CGI scripts usually run very quickly but frequently, while serious text-processing scripts may just suck up CPU cycles. The latter is much easier to monitor. The ps command is standard on every Unix system I've ever used, and you should be able to find a version of top for your platform for roughly realtime statistics. Execution time you can track by checking the system time at the beginning and end of your scripts, though this isn't very reliable for short-lived scripts.
Re: Testing Efficiency
by orthanc (Monk) on Aug 29, 2000 at 12:37 UTC

    Hi All,

    I find that 'ab', the apache benchmarking tool is nice for testing the load that CGI's produce.


Re: Testing Efficiency
by philz (Novice) on Aug 29, 2000 at 19:35 UTC
    The 'time' command (in /usr/bin, but tcsh has its own internal one), will show you how the perl script is doing system-wise. I use tcsh and have: set time=( 5 ge: %P%X+%Dk %I+%Oio %Fpf+%Ww' ) in my .tcshrc. e.g.: 'time ls':
    User mode: 0.000 Kernel mode: 0.005 Time: 0:00.00 CPU Percentage: 0.0% 0+0k 0+0io 0pf+0w
    Fun for the whole family. (The 5 in the set line makes processes that take over 5s of time always print out time statistics. Always works on make bzImage.)

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://30075]
Approved by root
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (3)
As of 2021-12-07 19:07 GMT
Find Nodes?
    Voting Booth?
    R or B?

    Results (34 votes). Check out past polls.