[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: time doesn't behave
From: |
EHV-00 |
Subject: |
Re: time doesn't behave |
Date: |
Tue, 10 Apr 2001 11:30:56 +0200 |
Dear Francis,
Adding the subshell-brackets does it for me....
Thanks a lot for your great help.
Kind Regards,
Eelco
"Francis Montagnac" <fm@sophia.inria.fr> wrote in message
news:9arp84$2j3$1@news-sop.inria.fr...
> In article <9akfos$gnu$1@porthos.nl.uu.net>,
> "EHV-00" <test@philips.com> writes:
> >Dear all,
>
> >I am trying to 'time' a process and grep the output.
> >For some reason the 'time' is not behaving correctly:
>
> >===>
> >eelco@ns6:~> time namp localhost 2>&1 | grep real
> >
> >real 0m0.455s
> >user 0m0.100s
> >sys 0m0.190s
>
> You should use a subshell to do that. Try:
>
> (time namp localhost) 2>&1 | grep real
>
> I use the following function to capture the realtime spent by a process:
>
> realtime() {
> {
> ( TIMEFORMAT="%R"; time { { "$@"; } >&4 2>&1 ; } ) 2>&1
> } 4>&2
> }
>
> then just say:
>
> var=$(realtime namp localhost)
>
> to store the real time spent in var.
>
> --
> Francis.Montagnac@sophia.inria.fr, Tel: (33)04 92 38 79 11
> INRIA Sophia, 2004, rte des Lucioles, B.P.93 - 06902 Sophia Antipolis
Cedex