[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 |
Hello,
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
#!/bin/bash
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>&-
done
echo 'all together took:'
exec 42>&-
What do you think, useful feature or unnecessary bloat?
--
Sami Kerola
http://www.iki.fi/kerolasa/
- feature: time builtin and file descriptor,
Sami Kerola <=
Re: feature: time builtin and file descriptor, Geir Hauge, 2014/10/31