[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

feature: time builtin and file descriptor

From: Sami Kerola
Subject: feature: time builtin and file descriptor
Date: Wed, 29 Oct 2014 14:09:53 +0000


Would it make sense to add to 'time' builtin a way to measure how long
a file descriptor is been kept open?  Something like this.

-- snip
exec 42>&0
time --file-descriptor 42
sleep 10
exec 42>&-
-- snip

$ ./above_script.sh
real    0m10.012s
user    0m0.000s
sys     0m0.000s

This idea came to my mind while writing a script that runs multiple
commands, and I simply wanted to know how long they are busy.  I am
aware alternatives exist, but they can get a bit tricky if one wants to
have multiple measurements going on simultaneously.  For example:

exec 42>&0
time --file-descriptor 42
for i in items; in
        exec 52>&0
        time --file-descriptor 52
        echo "processing $i"
        echo "item $i took"
        exec 52>&-
echo 'all together took:'
exec 42>&-

What do you think, useful feature or unnecessary bloat?

Sami Kerola

reply via email to

[Prev in Thread] Current Thread [Next in Thread]