I have to do a long task (convert image format) for every file of a folder. I achieved to use
pv
to write the estimation of duration with (used sleep
here to simulated processing time):
pv -B 1 =(find . -iwholename '*.png') | xargs -l sh -c 'sleep 0.1'
I was thinking like there may be an internal buffer which can mess up the estimation, because the list of files itself is not very large (tens of KB) and there may be internal buffer somewhere like in pv
, so I limited the buffer to 1 byte with -B 1
. And I wonder if that could cause performance issues (because disk can only read by a minimum of 512 bytes per read, and discard 511 bytes), but I don't know if maybe it resides it memory because =()
is used. I feel like -B 1
is a bad solution.
But more importantly, there are strange behaviour with others values for -B
. For example :
pv =(yes | head -n 100) -B 1 | xargs -l sh -c 'sleep 1'
Will work as expected (although starting strangely around 17%
and starting rendering only after a few seconds), but
pv =(yes | head -n 100) -B 10 | xargs -l sh -c 'sleep 1'
will print immediately 100%
even if I thought it should take 100 seconds to process, updating at interval of 5%
, because 200 bytes are printed, x100 characters y
and \n
. Why ?
**Note** : =()
requires zsh
. I tried with <()
and the progress bar doesn't work. Maybe pv
can't estimate the fifo size, but it can with a file?
Asked by rafoo
(121 rep)
Aug 2, 2022, 10:07 AM
Last activity: Aug 2, 2022, 05:55 PM
Last activity: Aug 2, 2022, 05:55 PM