How to measure peak memory usage
Posted 04-26-2015 at 07:46 AM by BenCollver
In the past, my method to measure peak memory usage was to boot a system, wait for it to become idle, run "free", run the program in question, then run "free" again. The difference is the memory usage. This method accounts for multi-process programs such as the LAMP stack, but it doesn't work as well for ephemeral command line utilities.
Today I ran across an easier way: Run the command line utility with /usr/bin/time -v. Example:
Today I ran across an easier way: Run the command line utility with /usr/bin/time -v. Example:
Code:
bash-4.2$ /usr/bin/time -v snzip -c <src.tar >src.snz Command being timed: "snzip -c" User time (seconds): 0.18 System time (seconds): 0.03 Percent of CPU this job got: 99% Elapsed (wall clock) time (h:mm:ss or m:ss): 0:00.22 Average shared text size (kbytes): 0 Average unshared data size (kbytes): 0 Average stack size (kbytes): 0 Average total size (kbytes): 0 Maximum resident set size (kbytes): 5536 Average resident set size (kbytes): 0 Major (requiring I/O) page faults: 0 Minor (reclaiming a frame) page faults: 425 Voluntary context switches: 1 Involuntary context switches: 24 Swaps: 0 File system inputs: 0 File system outputs: 30272 Socket messages sent: 0 Socket messages received: 0 Signals delivered: 0 Page size (bytes): 4096 Exit status: 0
Total Comments 1
Comments
-
Nice!
Posted 11-07-2023 at 02:15 AM by ychaouche