1

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.

BassKozz
  • 645
  • 2
  • 8
  • 15

3 Answers3

0

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.

Xorlev
  • 1,855
  • 14
  • 12
0

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.

McJeff
  • 2,039
  • 13
  • 11
0

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.

Warner
  • 23,756
  • 2
  • 59
  • 69