This is a utility to calculate CPU and memory usage for specific processes during a period of time. It is useful when you need to record these parameters for performance analysis in experiments. Especially, when there are multiple processes you need to record simultaneously, you can just specify the command name or pids. Then, the overall statistics will be generated by adding all up. It uses /proc filesystem to fetch usage information periodically. For instance, I retrieve CPU time information in /proc/:pid/stat and memory usage in /proc/:pid/statm.
cmrecord [-t<time>] -i<interval> -c<command>|-p<pids> -o<output>:
-t = total recording time(s), default is -1 for forever recording
-i = recording interval(s)
-o = output file
-p = pids seperated by .
-c = tracing command
The Memory Usage is only for resident set, which means I only calculate those resided in physical memory, not swapped out.
The CPU Usage is actually an average value between an interval. Since /proc/stat and /proc/:pid/stat only record cumulative CPU time, the result is for an estimated value at the intermediate time in the interval.
Author: Further Lee
License: GPL2