Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Ubuntu Server 9.10

So there is the time command which will show you the time it took for a specific process/command to run after the command has completed. For example:

:~$ time ls
real 0m0.020s
user 0m0.000s
sys 0m0.000s

I'd like to also collect the average CPU usage, Memory, and Disk (i/o) utilization after the process has completed using time (or another command if necessary). How can I accomplish this?

Mainly I am using this to benchmark MySQL import performance using different innodb_buffer_pool_size settings.

share|improve this question
This is not a very accurate test, the operating system may be caching data to, making you results unreliable. – The Unix Janitor Mar 20 '10 at 19:29
up vote 0 down vote accepted

That's kind of what the getrusage calls are meant for, though most of the fields are unused on Linux (at least that was the case the last time I had to care.

I usually just use top -p myself, as it limits top to the process I care about. You can then toggle additional fields in the usual fashion. For example, top -p 1 would only show the init process. You can then watch the performance of MySQL as you do your import.

You can watch CPU stats, memory usage (RSS & Virtual), faults, anything top would normally give you.

share|improve this answer

I'm not quite sure if this'll work exactly the way you want to, but vmstat <delay> will print out stats every seconds.

There's also sar which reads system stats automatically taken every 10 minutes, or however long sard is configured for.

share|improve this answer

Good question. In the context of MySQL, you might be better off using tools designed for that purpose. You have Sysbench, Supersmack, and others. See the links below.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.