LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   How long to complete a command.... (https://www.linuxquestions.org/questions/linux-general-1/how-long-to-complete-a-command-57615/)

cmfarley19 05-01-2003 06:41 AM

How long to complete a command....
 
I am in the process of going through a Linux From Scratch build. Some packages take quite a long time to build. I am interested in finding out how long they take. Is there some command or chain of commands that will tell me that?
Something like:

$ date &&
(LFS build commands here) &&
date


The trick is to get the difference of those two dates in seconds, minutes, whatever.

Any thoughts?

acid_kewpie 05-01-2003 06:55 AM

well you can see how long by just using "time" as a stopwatch effectively....

time make

etc....

cmfarley19 05-01-2003 07:07 AM

OK. I've played with time a little....
but....
LFS uses a chain of commands like:

patch -Np1 -i ../gawk.3.1.1-2.patch &&
./configure --prefix=/usr --libexecdir=/usr/bin &&
make &&
make install

So if I put time in front of the whole lot, will that time the whole thing or just the patch command?
I'm looking for the time for all of the commands to execute.

acid_kewpie 05-01-2003 07:28 AM

AFAIK....

time ( ./configure && make .... )

Mik 05-01-2003 07:55 AM

This is a script I use to display the duration of running several test scripts:

Code:

# display the duration in a logical string
duration ()
{
  totalsecs=$1
  secs=$(($totalsecs % 60))
  mins=$((($totalsecs % 3600) / 60))
  hours=$(($totalsecs / 3600))
 
  if [ $hours = 0 ] && [ $mins = 0 ]
  then
    result_str="$secs second(s)"
  elif [ $hours = 0 ]
  then
    result_str="$mins minutes(s) $secs second(s)"
  else
    result_str="$hours hour(s) $mins minute(s) $secs second(s)"
  fi

  echo $result_str
}

echo "Test started at `date`"
START_DATE=`date +%s`

#Do some stuff

echo "Test finished at `date`"
END_DATE=`date +%s`
echo "Test duration is `duration $(($END_DATE - $START_DATE))`"


cmfarley19 05-01-2003 09:02 AM

acid_kewpie - Could'nt get that to work.
Mik - your script works just fine. Just what I wanted.

I'm still open to hearing about other ways to accomplish this.

Thanks Mik & acid_kewpie


All times are GMT -5. The time now is 07:44 PM.