naim@eecs.nwu.edu (Naim Abdullah) (03/15/89)
How can one time a pipeline in the csh/sh so that the time returned is that of the longest running process in the pipeline ? So, for example running it on "ls | sleep 5" should return 5 seconds assuming that the ls finishes before then. A sample solution would be % time sh -c "ls | sleep 5" but that involves creating an extra process. Is there a clever quoting trick that would avoid the extra process ? Thanks. Naim Abdullah Dept. of EECS, Northwestern University Internet: naim@eecs.nwu.edu Uucp: {oddjob, chinet, att}!nucsrl!naim
ekrell@hector.UUCP (Eduardo Krell) (03/15/89)
In ksh, time is a builtin and it always returns the time of the entire pipe (what you were asking for), not the time of the first command in the pipe. Eduardo Krell AT&T Bell Laboratories, Murray Hill, NJ UUCP: {att,decvax,ucbvax}!ulysses!ekrell Internet: ekrell@ulysses.att.com
leo@philmds.UUCP (Leo de Wit) (03/16/89)
In article <3680044@eecs.nwu.edu> naim@eecs.nwu.edu (Naim Abdullah) writes: |How can one time a pipeline in the csh/sh so that the time returned |is that of the longest running process in the pipeline ? | |So, for example running it on "ls | sleep 5" should return 5 seconds |assuming that the ls finishes before then. | |A sample solution would be | |% time sh -c "ls | sleep 5" | |but that involves creating an extra process. Is there a clever |quoting trick that would avoid the extra process ? I would expect that % time eval 'ls|sleep 5' would perform your trick, but strange enough ls and sleep are executed one after another (parallel? at least no pipe). What is this, another csh bug (without 'time' the problem remains) ? Leo.