tags:

views:

92

answers:

2

we can use time in a unix environment to see how long something took...

shell> time some_random_command
real    0m0.709s
user    0m0.008s
sys     0m0.012s

is there an equivalent for recording memory usage of the process(es)?

in particular i'm interested in peak allocation.

A: 

Can you not use ps? e.g. ps v <pid> will return memory information.

Andy Whitfield
i was using ps but for short lived processes i was having trouble capturing the info
matpalm
+3  A: 

Check the man page for time. You can specify a format string where it is possible to output memory information. For example:

>time -f"mem: %M" some_random_command
mem: NNNN

will output maximum resident set size of the process during its lifetime, in Kilobytes.

Mathias