1

这是一个小脚本,用于在 mac os x 上测量 SD 卡(或 USB 记忆棒或其他磁盘)的速度。它非常原始,但易于使用和适应。

4

1 回答 1

5
#!/bin/bash
# config
SD_DIR=/Volumes/EOS_DIGITAL/
FILENAME=file_speed_test.deleteme
SIZE=5 # in MB (mac os x)

#create large file first
echo "creating file"
mkfile 100m $TMPDIR$FILENAME
echo "done creating file"

# measure time at the beginning
echo "Starting to WRITE to SD"
START=$(date +%s)
cp $TMPDIR$FILENAME $SD_DIR
END=$(date +%s)

#calculate diff
DIFFw=$(( $END - $START ))
SPEEDw=$(echo $SIZE/$DIFFw | bc -l)
echo "It took $DIFFw seconds to write"

# delete file 
rm $TMPDIR$FILENAME

# read speed
echo "Starting to READ from SD"
START=$(date +%s)
cp $SD_DIR$FILENAME $TMPDIR
END=$(date +%s)
rm $TMPDIR$FILENAME
rm $SD_DIR/$FILENAME

#calculate diff
DIFFr=$(( $END - $START ))
SPEEDr=$(echo $SIZE/$DIFFr | bc -l)
echo "It took $DIFFr seconds to read"

echo "---------- RESULTS ------------"
echo "It took $DIFFw seconds to write $SIZE MB --> WRITE Speed: $SPEEDw MB/s"
echo "It took $DIFFr seconds to read $SIZE MB  --> READ  Speed: $SPEEDr MB/s"
于 2013-01-01T20:56:47.763 回答