Difference between revisions of "drive speed tests"

From Noah.org
Jump to navigationJump to search
Line 98: Line 98:
 
#
 
#
 
#    This performs a very simple drive speed test. It measures sustained
 
#    This performs a very simple drive speed test. It measures sustained
#    write and read speed to a 128 MB file.
+
#    write and read speed to a 256 MB file.
 
#
 
#
 
# AUTHOR
 
# AUTHOR
Line 111: Line 111:
 
#        http://opensource.org/licenses/isc-license.txt
 
#        http://opensource.org/licenses/isc-license.txt
 
#
 
#
#    Copyright (c) 2010, Noah Spurrier <noah@noah.org>
+
#    Copyright (c) 2013, Noah Spurrier <noah@noah.org>
 
#
 
#
 
#    Permission to use, copy, modify, and/or distribute this software for any
 
#    Permission to use, copy, modify, and/or distribute this software for any
Line 127: Line 127:
 
# VERSION
 
# VERSION
 
#
 
#
#    Version 1
+
#    Version 2
 
#
 
#
  
echo "Uptime: $(uptime)"
+
# For a 128 MB file use BLOCK_COUNT=16 and BLOCK_SIZE=8388608.
 +
# For a 256 MB file use BLOCK_COUNT=32 and BLOCK_SIZE=8388608.
 +
BLOCK_COUNT=32
 +
BLOCK_SIZE=8388608
 +
OUTPUT_FILE="junk.bin"
 +
 
 +
if [ -d /dev/shm ]; then
 +
    echo "= Create source data file in /dev/shm/random.bin ="
 +
    SOURCE_DATA=/dev/shm/random.bin
 +
    rm -f ${SOURCE_DATA}
 +
    dd if=/dev/urandom of=${SOURCE_DATA} bs=${BLOCK_SIZE} count=${BLOCK_COUNT}
 +
else
 +
    echo "= WARNING: Using /dev/zero for data. Results may skewed fast. ="
 +
    SOURCE_DATA=/dev/zero
 +
fi
 +
 
 +
sync
 +
echo "uptime: $(uptime)"
 
PWD=$(pwd)
 
PWD=$(pwd)
echo "The current directory is ${PWD}."
+
echo "current directory: ${PWD}"
 
CURRENT_DEV=$(df -hT $(pwd) \
 
CURRENT_DEV=$(df -hT $(pwd) \
  | sed -n -e 's/^\(\/dev\/[a-zA-Z]\+[0-9]\+\).*/\1/p')
+
| sed -n -e 's/^\(\/dev\/[^[:space:]]\+\).*/\1/p')
 +
 
 
if [ "${CURRENT_DEV}" = "" ]; then
 
if [ "${CURRENT_DEV}" = "" ]; then
  echo "Cannot find device associated with this directory."
+
    echo "WARNING: Did not find device associated with current directory."
 
else
 
else
  echo "The current directory is stored on ${CURRENT_DEV}"
+
    echo "mount device: ${CURRENT_DEV}"
  if echo ${CURRENT_DEV} | grep -q /dev/md; then
+
    echo "drive mount options: $(grep ${CURRENT_DEV} /etc/mtab)"
    echo "This device is part of a sofware RAID."
+
    if grep ${CURRENT_DEV} /etc/mtab | grep -iq sync; then
    echo "The software RAID is configured as follows:"
+
        echo "   WARNING: sync option will effect write speed tests."
    echo -en "\t"
+
    fi
    egrep 'md[0-9]+' /proc/mdstat
+
    if echo ${CURRENT_DEV} | grep -q /dev/md; then
    CURRENT_DEV=$(egrep 'md[0-9]+' /proc/mdstat \
+
        echo "   This device is a sofware RAID configured as follows:"
      |sed -n -e 's/.*[[:space:]]\([a-z]*[0-9]*\)\[.\]$/\1/p')
+
        echo -en "       "
    CURRENT_DEV="/dev/${CURRENT_DEV}"
+
        egrep 'md[0-9]+' /proc/mdstat
    echo -n "The last drive in the array is "
+
        CURRENT_DEV=$(egrep 'md[0-9]+' /proc/mdstat \
  fi
+
            |sed -n -e 's/.*[[:space:]]\([a-z]*[0-9]*\)\[.\]$/\1/p')
  hdparm -I ${CURRENT_DEV} | sed -n -e '/^$/d' \
+
        CURRENT_DEV="/dev/${CURRENT_DEV}"
    -e '0,/Standards:/p' | sed -n -e '$!p'
+
        echo "   Drive info will be taken from last device in the array."
 +
    fi
 +
    # Try `hdparm` otherwise try `lsusb`.
 +
    if ! DRIVE_INFO=$(hdparm -I ${CURRENT_DEV} | sed -n -e '/^$/d' \
 +
        -e '0,/Standards:/p' | sed -n -e '$!p'); then
 +
    DRIVE_INFO=$(lsusb)
 
fi
 
fi
 +
DRIVE_INFO=$(echo ${DRIVE_INFO})
 +
echo "drive info: ${DRIVE_INFO}"
 +
fi
 +
 +
echo
 
echo "Running test three times..."
 
echo "Running test three times..."
 +
 
for n in 1 2 3; do
 
for n in 1 2 3; do
  sync
+
    echo -n "test ${n}: "
  dd if=/dev/zero of=junk.bin oflag=dsync conv=fdatasync \
+
    sync
    bs=8388608 count=16 2>&1|grep "copied"|cut -f1,6 -d" " \
+
    dd if=${SOURCE_DATA} of=${OUTPUT_FILE} oflag=dsync conv=fdatasync \
    |awk '{printf("write: %7.2f MB/s, ",$1/$2/(1024*1024))}'
+
        bs=${BLOCK_SIZE} count=${BLOCK_COUNT} 2>&1|grep "copied"|cut -f1,6 -d" " \
  sync
+
        |awk '{printf("write: %7.2f MB/s, ",$1/$2/(1024*1024))}'
  dd if=junk.bin iflag=direct conv=fdatasync of=/dev/null \
+
    sync
    bs=8388608 count=16 2>&1|grep "copied"|cut -f1,6 -d" " \
+
    if [ ! -e /dev/zero ]; then
    |awk '{printf("read:  %7.2f MB/s\n",$1/$2/(1024*1024))}'
+
        rm ${SOURCE_DATA}
  rm junk.bin
+
    fi
 +
    dd if=${OUTPUT_FILE} iflag=direct conv=fdatasync of=${SOURCE_DATA} \
 +
        bs=${BLOCK_SIZE} count=${BLOCK_COUNT} 2>&1|grep "copied"|cut -f1,6 -d" " \
 +
        |awk '{printf("read:  %7.2f MB/s\n",$1/$2/(1024*1024))}'
 +
    rm junk.bin
 
done
 
done
# vim:set sr et ts=4 sw=4 ft=sh: // See Vim, :help 'modeline'
+
 
 +
if [ -e /dev/shm/random.bin ]; then
 +
    rm ${SOURCE_DATA}
 +
fi
 +
 
 +
# vim:set ft=sh sr et ts=4 sw=4: // See Vim, :help 'modeline'
 
</pre>
 
</pre>
  

Revision as of 17:49, 7 January 2013


drive speed test results -- trivial benchmarks

Raw read and write speed may not the best benchmark, but it's a start. For USB Flash drives this is usually the benchmark that I care about the most since I usually use USB Flash drives for moving large files around.

write speed in MB/s read speed in MB/s drive name / model USB ID Notes
6.36 19.88 Pie Digital, Inc. PieKey 4GB 22a6:ffff This was from a Flash drive I worked on -- I set the PID! Pretty decent specs.
9.87 17.71 Pie Digital, Inc. PieKey 1GB early prototype 04fe:0006
98.11 189.85 SanDisk Extreme CZ80 USB 3.0 32GB 0781:5580 Super fast! test-drive-speed V2. It appears actually to be this fast. Serial Number: 03e9a18ef Firmware Revision: ER.24.00 Transport: Serial, ATA8-AST, SATA Rev 2.6, SATA Rev 3.0
38.88 81.37 Corsair Voyager Slider 32GB USB3 Model CMFSL3-32GB 1b1c:1a06
35.99 68.42 Kingston Technology 32GB USB3 0951:168e test-drive-speed V2
4.34 22.63 SanDisk Cruzer Fit 16GB 0781:5571 This USB flash drive is a little nub hardly bigger than the USB plug.
4.20 22.62 SanDisk Cruzer Facet 8GB 0781:5576
4.01 18.10 SanDisk Cruzer 16GB SDCZ36-016G 0781:5530
4.32 18.67 Lexar Media 4GB 05dc:a768
4.01 15.45 Alcor Micro Corp. 2GB 058f:6387 This was from a free Jaguar car keyfob schwag. It was kind of crappy.
3.51 23.76 Transcend Information OCZ Diesel 4GB 1307:0165
10.27 17.50 OEM 2GB 13fe:1f00 Impressive write speed for a cheap drive.
6.64 15.58 Cisco Linksys Connect Easy Setup Key 1GB / NK2 13b1:002e
44.83 78.78 Seagate Momentus 7200.3 / ST9160411ASG Serial Number: 5TG0K2CB Firmware Revision: DE17
28.14 120.80 Transcend 2.5" SATA-2 SSD / TS64GSSD25S-M Serial Number: 002538030036 Firmware Revision: V090216
70.98 125.97 OCZ VERTEX-LE Serial Number: f0409001b, Firmware Revision: 1.05
73.17 166.16 apocalypse.dreamhost.com Run on a shared hosting service. Drive specs unknown. Quite fast for a shared host.
115.82 534.99 Amazon EC2 184.72.242.0 Amazon EC2 West Coast server. Write speeds vary drastically. Average of 18 runs. Look at that read speed!
131.15 269.65 Amazon EC2 184.72.18.0 Amazon EC2 West Coast server. Write speeds vary drastically. Average of 9 runs.
53.00 106.97 Hitachi HTS545050A7E380 through SimpleTech USB3 4971:8013 Firmware Revision: GG2OA7A0
WRITE READ NAME USBID COMMENTS

Do not mount with sync option

The first test run shows that write performance is over 12 times slower when the drive is mounted with the sync option versus the second test without the sync option. The other options have little effect. These tests were run on a USB flash drive.

first test

/dev/sdb1 on /media/usb0 type vfat (rw,noexec,nodev,sync,noatime,nodiratime)

Running test three times...
test 1: write:    0.34 MB/s, read:    18.67 MB/s
test 2: write:    0.34 MB/s, read:    18.61 MB/s
test 3: write:    0.34 MB/s, read:    18.29 MB/s

second test

/dev/sdb1 on /media/usb0 type vfat (rw)

Running test three times...
test 1: write:    4.32 MB/s, read:    18.51 MB/s
test 2: write:    4.32 MB/s, read:    18.51 MB/s
test 3: write:    4.31 MB/s, read:    18.46 MB/s

trivial benchmark tool

You can use `dd` to measure sustained drive throughput if you do it right. You want to bypass any cache and buffering in the I/O path. This is not hard, but it is uncommon enough that it can be difficult to find documentation on the correct options to use.

It is unclear if this will also bypass RAID controller cache. It almost certainly will not bypass the cache on the drive itself. You would need to activate additional option via `hdparm` if your drive offers them. I considered this a little too invasive and I wasn't sure if the options would be the same for every drive. Plus I figured that the drive controller cache is not really an optional component of the drive, so there is no reason to take it out of the equation; although, it does make it more difficult to interpret read-speed tests.

the most trivial drive benchmark tool

alias test-drive-speed='dd if=/dev/zero of=test_data.bin oflag=dsync conv=fdatasync  bs=8388608 count=16 2>&1 | grep "bytes" | cut -f1,6 -d" " | awk '\''{printf ("write-speed: %7.2f MB/s, ", $1 / $2 / (1024*1024))}'\'' && dd if=test_data.bin iflag=direct conv=fdatasync of=/dev/null bs=8388608 count=16 2>&1 | grep "copied" | cut -f1,6 -d" " | awk '\''{printf ("read-speed:  %7.2f MB/s\n", $1 / $2 / (1024*1024))}'\'''

slightly less trivial benchmark tool

#!/bin/bash
#
# test-drive-speed
#
# DESCRIPTION
#
#     This performs a very simple drive speed test. It measures sustained
#     write and read speed to a 256 MB file.
#
# AUTHOR
#
#     Noah Spurrier <noah@noah.org>
#
# LICENSE
#
#     This license is OSI and FSF approved as GPL-compatible.
#     This license identical to the ISC License and is registered with and
#     approved by the Open Source Initiative. For more information vist:
#         http://opensource.org/licenses/isc-license.txt
#
#     Copyright (c) 2013, Noah Spurrier <noah@noah.org>
#
#     Permission to use, copy, modify, and/or distribute this software for any
#     purpose with or without fee is hereby granted, provided that the above
#     copyright notice and this permission notice appear in all copies.
#
#     THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
#     WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
#     MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
#     ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
#     WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
#     ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
#     OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#
# VERSION
#
#     Version 2
#

# For a 128 MB file use BLOCK_COUNT=16 and BLOCK_SIZE=8388608.
# For a 256 MB file use BLOCK_COUNT=32 and BLOCK_SIZE=8388608.
BLOCK_COUNT=32
BLOCK_SIZE=8388608
OUTPUT_FILE="junk.bin"

if [ -d /dev/shm ]; then
    echo "= Create source data file in /dev/shm/random.bin ="
    SOURCE_DATA=/dev/shm/random.bin
    rm -f ${SOURCE_DATA}
    dd if=/dev/urandom of=${SOURCE_DATA} bs=${BLOCK_SIZE} count=${BLOCK_COUNT}
else
    echo "= WARNING: Using /dev/zero for data. Results may skewed fast. ="
    SOURCE_DATA=/dev/zero
fi

sync
echo "uptime: $(uptime)"
PWD=$(pwd)
echo "current directory: ${PWD}"
CURRENT_DEV=$(df -hT $(pwd) \
 | sed -n -e 's/^\(\/dev\/[^[:space:]]\+\).*/\1/p')

if [ "${CURRENT_DEV}" = "" ]; then
    echo "WARNING: Did not find device associated with current directory."
else
    echo "mount device: ${CURRENT_DEV}"
    echo "drive mount options: $(grep ${CURRENT_DEV} /etc/mtab)"
    if grep ${CURRENT_DEV} /etc/mtab | grep -iq sync; then
        echo "    WARNING: sync option will effect write speed tests."
    fi
    if echo ${CURRENT_DEV} | grep -q /dev/md; then
        echo "    This device is a sofware RAID configured as follows:"
        echo -en "        "
        egrep 'md[0-9]+' /proc/mdstat
        CURRENT_DEV=$(egrep 'md[0-9]+' /proc/mdstat \
            |sed -n -e 's/.*[[:space:]]\([a-z]*[0-9]*\)\[.\]$/\1/p')
        CURRENT_DEV="/dev/${CURRENT_DEV}"
        echo "    Drive info will be taken from last device in the array."
    fi
    # Try `hdparm` otherwise try `lsusb`.
    if ! DRIVE_INFO=$(hdparm -I ${CURRENT_DEV} | sed -n -e '/^$/d' \
        -e '0,/Standards:/p' | sed -n -e '$!p'); then
    DRIVE_INFO=$(lsusb)
fi
DRIVE_INFO=$(echo ${DRIVE_INFO})
echo "drive info: ${DRIVE_INFO}"
fi

echo
echo "Running test three times..."

for n in 1 2 3; do
    echo -n "test ${n}: "
    sync
    dd if=${SOURCE_DATA} of=${OUTPUT_FILE} oflag=dsync conv=fdatasync \
        bs=${BLOCK_SIZE} count=${BLOCK_COUNT} 2>&1|grep "copied"|cut -f1,6 -d" " \
        |awk '{printf("write: %7.2f MB/s, ",$1/$2/(1024*1024))}'
    sync
    if [ ! -e /dev/zero ]; then
        rm ${SOURCE_DATA}
    fi
    dd if=${OUTPUT_FILE} iflag=direct conv=fdatasync of=${SOURCE_DATA} \
        bs=${BLOCK_SIZE} count=${BLOCK_COUNT} 2>&1|grep "copied"|cut -f1,6 -d" " \
        |awk '{printf("read:  %7.2f MB/s\n",$1/$2/(1024*1024))}'
    rm junk.bin
done

if [ -e /dev/shm/random.bin ]; then
    rm ${SOURCE_DATA}
fi

# vim:set ft=sh sr et ts=4 sw=4: // See Vim, :help 'modeline'

Online guides

http://www.harddrivebenchmark.net/