1

I am profiling the speed at which a certain Linux program reads a certain input file using different amount of threads by doing this:

time ~/src/myprogram -t $t inputfile 1>/dev/null 2>/dev/null

It seems like no matter what number of threads I use, starting from 12 down to 1, the time is exactly the same. Is there any other way to test this to make sure it is not influenced by the speed that data is sent to /dev/null?

719016
  • 4,683

1 Answers1

1

The kernel caches I/O read from incoming block devices in free RAM. Unless your file is very large you are probably hitting the cached data in RAM and not actually causing any I/O.

A very quick search and reading this Stack Overflow answer reveals that this might do it:

sync && echo 1 > /proc/sys/vm/drop_caches

so I would try issuing those command before the command that performs the I/O.

LawrenceC
  • 75,182