mohan
mohan

Reputation: 1530

Average working set size for a process

I am running an executable in linux (c++ code). I want to calculate 'average' working set size of this executable? I have no clue in how to proceed. Can some one help me out?

Is there any command in linux to do so?

Thanks in advance

Upvotes: 0

Views: 1863

Answers (1)

Seth Robertson
Seth Robertson

Reputation: 31461

Inspired by Caesar:

pid=`ps axo 'pid,ucomm' | grep procname | awk '{print $1;}'`
while sleep 15; do grep VmRSS /proc/$pid/status || break; done > /tmp/size
awk '{ sum += $2; count++; } END { print sum/count; }' /tmp/size

Upvotes: 3

Related Questions