LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Blogs > BenCollver
User Name
Password

Notices


Rate this Entry

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:

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
Posted in Uncategorized
Views 2265 Comments 1
« Prev     Main     Next »
Total Comments 1

Comments

  1. Old Comment
    Nice!
    Posted 11-07-2023 at 02:15 AM by ychaouche ychaouche is offline
 

  



All times are GMT -5. The time now is 12:01 AM.

Main Menu
Advertisement
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration