write: 13.40 MB/s read: 27.27 MB/sNote: above 1 MB/s corresponds to 1024*1024 bytes/s. In dd 1 MB/s corresponds to 1000*1000 bytes/s. Interesting to note is that the
sync
mount option kills the performance, therefore the script:
#!/bin/bash GB_COUNT=3 GB_SIZE=1000 MOUNT_OPTIONS="-o flush,uid=$UID" flash_device=$1 flash_mount_point=/tmp/$RANDOM READSPEED=0 WRITESPEED=0 function mount_flash { mounted=$(mount -l | grep $flash_device) if [ -z "$mounted" ] then echo "mounting..." sudo mount $MOUNT_OPTIONS $flash_device $flash_mount_point fi } function umount_flash { UNMOUNTING=$(date +%s) mounted=$(mount -l | grep $flash_device) while [ ! -z "$mounted" ] do echo "unmounting $flash_device ..." sudo umount $flash_device mounted=$(mount -l | grep $flash_device) done UNMOUNTED=$(date +%s) echo "! device $flash_device unmounted in $(($UNMOUNTED-$UNMOUNTING)) sec" } function init { mkdir -p $flash_mount_point if [ -z "$flash_device" ] || [ ! -b "$flash_device" ] then echo "Invalid device specified:[$flash_device]" exit fi umount_flash mount_flash echo "" echo " Read/Write Benchmark" echo "==============================" echo "! device: $flash_device" echo "! mounted: $(sudo mount -l | grep $flash_device)" echo "!" echo "==============================" echo "" } function write_test { mount_flash START=$(date +%s) for i in $(seq 1 1 $GB_COUNT) do echo " writing $GB_SIZE MB: $i of $GB_COUNT" dd count=$GB_SIZE bs=1M if=/dev/zero of=$flash_mount_point/test.$i done echo "! unmounting.." umount_flash END=$(date +%s) TIME=$(($END-$START)) echo "! writting $(($GB_COUNT*$GB_SIZE)) MB done in: $TIME sec" echo "" integ=$(($GB_SIZE*$GB_COUNT/$TIME)) frac=$((100*$GB_SIZE*$GB_COUNT/$TIME-100*$integ)) WRITESPEED=$integ.$frac echo "! write: $WRITESPEED MB/s" } function read_test { mount_flash START=$(date +%s) for i in $(seq 1 1 $GB_COUNT) do echo " reading $GB_SIZE MB: $i of $GB_COUNT" dd count=1000 bs=1M of=/dev/null if=$flash_mount_point/test.$i done umount_flash END=$(date +%s) TIME=$(($END-$START)) echo "! reading $(($GB_COUNT*$GB_SIZE)) MB done in: $TIME sec" echo "" integ=$(($GB_SIZE*$GB_COUNT/$TIME)) frac=$((100*$GB_SIZE*$GB_COUNT/$TIME-100*$integ)) READSPEED=$integ.$frac echo "! read: $READSPEED MB/s" } init write_test read_test echo "======================" echo " Benchmark Result:" echo "" echo " write: $WRITESPEED MB/s" echo " read: $READSPEED MB/s" echo "" echo "======================"Worth reading - http://www.hjreggel.net/cardspeed