Sample Header Ad - 728x90

Measuring disk I/O usage of a program

14 votes
1 answer
2968 views
time is a brilliant command if you want to figure out how much CPU time a given command takes. I am looking for something similar that can measure the disk I/O of the program and any children. Preferably it should distinguish between I/O that was cached (and thus did not cause the disk to spin) and I/O that was not cached. So I would like to do: iomeassure my_program my_args and get output similar to: Cached read: 10233303 Bytes Cached write: 33303 Bytes # This was probably a tmp file that was erased before making it to the disk Non-cached read: 200002020 Bytes Non-cached write: 202020 Bytes I have looked at vmstat, iostat, and sar, but none of these are looking at a single process. Instead they look at the whole system. I have looked at iotop, but that only gives me a view this instant. --- edit --- snap's answer seems close. 'File system inputs:' is the non-cached reads in 512-byte blocks. 'File system outputs:' is the cached writes in 512-byte blocks. You can force the cache empty with: sync ; echo 3 | sudo tee /proc/sys/vm/drop_caches >/dev/null I tested with: seq 10000000 > seq /usr/bin/time -v bash -c 'perl -e "open(G,\">f\"); print G ;close G; unlink \"f\";" seq'
Asked by Ole Tange (37348 rep)
Aug 16, 2011, 02:11 PM
Last activity: Oct 25, 2020, 04:17 PM