Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re^3: Optimizing a large project.

by salva (Canon)
on Jun 13, 2008 at 08:15 UTC ( [id://691858]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Optimizing a large project.
in thread Optimizing a large project.

To know where the problem lies, if in IO or in CPU usage, all you need to do is to run top or any other similar monitoring tool while your program is running. Roughly, if it shows that CPU usage goes over 90%, then your problem is CPU, below 30% it is IO and in the middle it is both.

Well, this method will not work if your application just receives a few events per minute that are processed in less than a second, below the top (and your eyes!) resolution.

Replies are listed 'Best First'.
Re^4: Optimizing a large project.
by salva (Canon) on Jun 13, 2008 at 08:48 UTC
    In the later case, to calculate the CPU usage ratio, you can use something like that:
    my ($cpu_time, $clock_time) = (0, 0); sub your_event_processing { my ($start_user, $start_system) = times; my $start_clock = time; # do the event processing here # ... my ($end_user,$end_system) = times; my $end_clock = time; $clock_time += ($end_clock - $start_clock); $cpu_time += ($end_user - $start_user + end_system - $start_system); } END { printf STDERR "clock_time: %d, cpu_time: %d (%4.2f%%)\n", $clock_time, $cpu_time, $cpu_time * 100 / $clock_time; }
    And let it run for some hundreds of events, so that the rounding errors go away.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://691858]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (1)
As of 2024-04-25 04:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found