If using "dd" there's also the "direct" flag:

# time dd if=/dev/hda of=/dev/null bs=1048576 count=16
16777216 bytes (17 MB) copied, 0.299895 s, 55.9 MB/s
# time dd if=/dev/hda of=/dev/null bs=1048576 count=16
16777216 bytes (17 MB) copied, 0.023379 s, 718 MB/s
# time dd if=/dev/hda iflag=direct of=/dev/null bs=1048576 count=16
16777216 bytes (17 MB) copied, 0.291149 s, 57.6 MB/s

The first two commands above are the same while the third uses the
"direct" flag.

- neil

On Fri, Apr 03, 2009 at 11:08:33AM +1300, John Carter wrote:
> 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 : [email protected]
> New Zealand
> 

Reply via email to