When benchmarking programs on linux systems I find cache effects
dominate.

ie. On current systems the difference in speed between RAM and disk is
so vast... that 2 orders of magnitude differences in algorithms can be
swallowed entirely by whether the data is in a ram disk buffer or on
disk.

So linux has a way of flushing clean caches....

echo 3 > /proc/sys/vm/drop_caches

For example... cat the cat program to /dev/null twice to make the
cache "hot", measure the time on a "hot" cache.

Then sync and drop the caches and do it on a cold cache.

cat /bin/cat > /dev/null;time cat /bin/cat > /dev/null;sync;sudo bash -c 'echo 3 > 
/proc/sys/vm/drop_caches';time cat /bin/cat > /dev/null

real    0m0.002s
user    0m0.000s
sys     0m0.004s

real    0m0.172s
user    0m0.000s
sys     0m0.008s

86x slower!

John Carter                             Phone : (64)(3) 358 6639
Tait Electronics                        Fax   : (64)(3) 359 4632
PO Box 1645 Christchurch                Email : john.car...@tait.co.nz
New Zealand

Reply via email to