6

I'm trying measure the concurrency efficiency of my web application (running in TomCat) during load testing. I'm looking for a way to get the average CPU utilization of my process spanning the start and end of load testing. What utility can I use to measure the cpu utilization of a process between 2 time points?

1
  • Just note the usage before, note the usage after, and subtract. Sep 17, 2013 at 21:13

2 Answers 2

4

The following command gets the average of CPU and memory usage every 40 seconds for a specific process(pid)

pidstat 40 -ru -p <pid>

Output for my case(first two lines for CPU usage, second two lines for memory):

02:15:07 PM       PID    %usr %system  %guest    %CPU   CPU  Command
02:15:47 PM     24563    0.65    0.07    0.00    0.73     3  java

02:15:07 PM       PID  minflt/s  majflt/s     VSZ    RSS   %MEM  Command
02:15:47 PM     24563      6.95      0.00 13047972 2123268   6.52  java
2

What you want is (CPU time) / (elapsed time). Note that if you have more than one processor, the value can go > 1.

PID=<The pid of your process>
ps -o pid,comm,etime,time -p $PID

You will get an output like

 PID COMMAND             ELAPSED     TIME
3545 ******                30:03 00:54:41

Its average CPU load is (54*60 + 41) / (30*60 + 3) = 1.82

1
  • 1
    and they'll need to restart the tomcat process at the beginning of the load test, or subtract the TIME and ELAPSED value from the beginning.
    – Matt
    Sep 18, 2013 at 9:07

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .