I run a benchmark several times, to note down the mean reading. But I notice that after the first run, the subsequent runs are faster. I guess it has something to do with the Instruction Cache, so when I run the program next time, the benchmark already has instructions in the cache. Is there a way to start a program with both cold instruction and data caches?
This is a normal behavior. One way to avoid this problem is run few warm up before the main run. These warm up runs will overwrite the cache memory that grown up previously running program. While calculating the mean value, exclude the warm up runs values only take real run. A various bench marking tools out there which takes these approach like. kernbench, lmbench etc. Where a warmup value is available.
And, if the benchmark you're running depends on data that needs to read from disk then, disk caching has some impact too, one way to avoid is to caching those data onto ram, if possible. This technique is used in kernbench, to avoid, disk cache related issue.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With