In Ubuntu, /usr/bin/time -v any-command
tells me the memory usage of any-command
and some information.
(Source: https://stackoverflow.com/a/774601/2885946)
I want to do the same thing in OS X/macOS.
Could you tell me how to get the memory usage of a process on OS X like /usr/bin/time -v
in Ubuntu?
View CPU activity on your Mac in the Activity Monitor window. To enable viewing in the Dock, choose View > Dock Icon, then select the Show CPU option you want to view. In the Activity Monitor app on your Mac, do any of the following: To view processor activity over time, click CPU (or use the Touch Bar).
You can use the Apple-supplied /usr/bin/time
as follows without installing anything:
/usr/bin/time -l <DO SOMETHING>
It is important to use the full path /usr/bin/time
because time
calls bash and results in error: -bash: -l: command not found
Sample Output
0.04 real
0.00 user
0.00 sys
2830336 maximum resident set size <-- peak memory usage
0 average shared memory size
0 average unshared data size
0 average unshared stack size
462 page reclaims
253 page faults
0 swaps
13 block input operations
3 block output operations
0 messages sent
0 messages received
0 signals received
26 voluntary context switches
94 involuntary context switches
For me, the next command works great:
ps -axm -o %mem,rss,comm | grep <programm name>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With