[KLUG Members] bash command benchmarking

greenproc greenproc at charter.net
Tue May 9 16:38:15 EDT 2006


Does anyone know of simple way to benchmark how long it takes for a command to complete?

Take the following as an example 1:

#
# tar --bzip2 cf /mnt/sdb2/Backup/Testing.bz2 /mnt/sdb2/Testing
#

After the command is issued, the directory /mnt/sdb2/Testing is tarred and bzipped into the Testing.bz2 file, and I am returned to the bash prompt.

Take the following as example 2:

#
# tar cfz /mnt/sdb2/Backup/Testing.gz /mnt/sdb2/Testing
#

Again, after the command is issued, the directory /mnt/sdb2/Testing is tarred and then *gzipped* into the Testing.gz file, and I am returned to
the bash prompt.

The goal is to have a print to the console, before the bash prompt is returned, say something like:

#
# tar --bzip2 cfv /mnt/sdb2/Backup/Testing.bz2 /mnt/sdb2/Testing
#
# command completed in 26.048 seconds
# sid1 at testing:/mnt/sdb2$
#

In that way, one can see how much longer it takes to do something one way over another by comparing the execution times of 'Example 1" and
"Example 2". Having a simple way to benchmark how long a command takes to complete has too many uses and benifits to list, and I would be
surprised if a simple method did not already exist.


More information about the Members mailing list