简体   繁体   English

用于在Mac OS X上读取/写入的SD卡速度的Shell脚本

[英]shell script to measure SD card speed read/write on mac os x

here is a small script to measure the speed of a SD card (or USB stick, or other Disk) on mac os x. 这是一个小脚本,用于测量Mac OS X上SD卡(或USB记忆棒或其他磁盘)的速度。 It is very primitive, but easy to use and adapt. 它非常原始,但是易于使用和适应。

#!/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"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM