[KLUG Members] bash command benchmarking

Jason Edward Durrett jed at shackman.com
Tue May 9 17:08:35 EDT 2006


In bash you can use time


greenproc wrote:
> 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
> #
> 

so, this would be:

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


and to do two commands,

#time tar --bzip2 cf /mnt/sdb2/Backup/Testing.bz2 /mnt/sdb2/Testing |
tar cfz /mnt/sdb2/Backup/Testing.gz /mnt/sdb2/Testing



> 
> 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$
> #

I don't know how to make it look like that - however, you can change the
output by setting the TIMEFORMAT variable.



More information about the Members mailing list