Linux Simple Benchmark with gnu time

This is used to show the runtime length of an executable in linux. It also shows the memory usage.

Download and compile GNU Time
http://directory.fsf.org/project/time/

wget http://ftp.gnu.org/pub/gnu/time/time-1.7.tar.gz
tar -xvzf time-1.7.tar.gz
cd time-1.7
./configure
make
make install
ln -s `pwd`/time /usr/local/bin/time

Add an alias to ~/.bashrc

alias gtime='/usr/local/bin/time -f "User: %U -- System: %S -- Elapsed: %E -- CPU: %P -- Max Res Memory: %MkB"'

Use the command to run a benchmark

gtime ./program

The output looks something like this:

User: 40.59 -- System: 0.08 -- Elapsed: 0:40.89 -- CPU: 99% -- Max Res Memory: 312944kB

Leave a Comment