How to use pv and fifo to measure the speed of anything

A FIFO (first in first out) is a special kind of file on linux. It's basically a pipe that looks like a file. Linux Journal has a good introduction to named pipes pv is a very helpful little command line programme for monitoring the progress of data through a pipe, and showing how much has progressed, throughput rate and estimated time till it's done. If there's a long operation you can pipe the input through pv and see how far it's going and how long it's going to take. However some programmes don't/can't accept input from a pipe, you must use a file. I think mysqlimport is like this.

You can use FIFOs and pv to get a progress bar. In one terminal, create the FIFO with mkfifo pipe.fifo Then pipe your big file into this FIFO using pv to get a status bar pv bigfile > pipe.fifo

You won't see anything and you won't get your prompt back. FIFOs don't take from their input, unless something is trying to read that input. In another terminal, run your big command, using the fifo name as the filename. It will read from the 'file', which causes the pv to pipe stuff into it, which means the progress bar will appear. bigcommand bigfile

When you're done, you can remove the FIFO 'file' since it's not really needed.

Related: Using pv to measure compression speed

This entry is tagged: