因项目需求,写了一个读写eMMC 的脚本来测试eMMC 读写速度
写速度测试脚本:
#!/bin/bash
TEST_FILE_SIZE=134217728
Block sizes of 512b 1K 2K 4K 8K 16K 32K 64K 128K 256K 512K 1M 2M 4M 8M 16M 32M 64M
for BLOCK_SIZE in 512 1024 2048 4096 8192 16384 32768 65536 131072 262144 524288 1048576 2097152 4194304 8388608 16777216 33554432 67108864
do
Calculate number of segments required to copy
COUNT=
(
(
((
((TEST_FILE_SIZE/$BLOCK_SIZE))
if [ $COUNT -le 0 ];
then
echo"Block size of $BLOCK_SIZE estimated to require
C
O
U
N
T
b
l
o
c
k
s
,
a
b
o
r
t
i
n
g
f
u
r
t
h
e
r
t
e
s
t
s
.
"
b
r
e
a
k
f
i
e
c
h
o
3
>
/
p
r
o
c
/
s
y
s
/
v
m
/
d
r
o
p
c
a
c
h
e
s
d
d
i
f
=
/
d
e
v
/
z
e
r
o
o
f
=
/
v
a
r
/
t
e
s
t
.
d
b
f
b
s
=
COUNT blocks, aborting further tests." break fi echo 3>/proc/sys/vm/drop_caches dd if=/dev/zero of=/var/test.dbf bs=
COUNTblocks,abortingfurthertests."breakfiecho3>/proc/sys/vm/dropcachesddif=/dev/zeroof=/var/test.dbfbs=BLOCK_SIZE count=$COUNT;sync
rm /var/test.dbf
sync
done
测试结果:
262144+0 records in
262144+0 records out
134217728 bytes transferred in 7.305 secs (18373405 bytes/sec)
131072+0 records in
131072+0 records out
134217728 bytes transferred in 4.859 secs (27622500 bytes/sec)
65536+0 records in
65536+0 records out
134217728 bytes transferred in 3.894 secs (34467829 bytes/sec)
32768+0 records in
32768+0 records out
134217728 bytes transferred in 3.434 secs (39084952 bytes/sec)
16384+0 records in
16384+0 records out
134217728 bytes transferred in 2.845 secs (47176705 bytes/sec)
8192+0 records in
8192+0 records out
134217728 bytes transferred in 2.851 secs (47077421 bytes/sec)
4096+0 records in
4096+0 records out
134217728 bytes transferred in 2.830 secs (47426759 bytes/sec)
2048+0 records in
2048+0 records out
134217728 bytes transferred in 3.035 secs (44223304 bytes/sec)
1024+0 records in
1024+0 records out
134217728 bytes transferred in 3.277 secs (40957500 bytes/sec)
512+0 records in
512+0 records out
134217728 bytes transferred in 3.023 secs (44398851 bytes/sec)
256+0 records in
256+0 records out
134217728 bytes transferred in 2.680 secs (50081241 bytes/sec)
128+0 records in
128+0 records out
134217728 bytes transferred in 2.869 secs (46782059 bytes/sec)
64+0 records in
64+0 records out
134217728 bytes transferred in 2.981 secs (45024397 bytes/sec)
32+0 records in
32+0 records out
134217728 bytes transferred in 3.095 secs (43365986 bytes/sec)
16+0 records in
16+0 records out
134217728 bytes transferred in 2.985 secs (44964062 bytes/sec)
8+0 records in
8+0 records out
134217728 bytes transferred in 2.915 secs (46043817 bytes/sec)
4+0 records in
4+0 records out
134217728 bytes transferred in 2.914 secs (46059618 bytes/sec)
2+0 records in
2+0 records out
134217728 bytes transferred in 2.957 secs (45389830 bytes/sec)
====================================================================
读eMMC 脚本:
#!/bin/bash
TEST_FILE_SIZE=134217728
Create test file
echo ‘Generating test file…’
BLOCK_SIZE=65536
COUNT=
(
(
((
((TEST_FILE_SIZE /
B
L
O
C
K
S
I
Z
E
)
)
d
d
i
f
=
/
d
e
v
/
u
r
a
n
d
o
m
o
f
=
/
v
a
r
/
t
e
s
t
.
d
b
f
b
s
=
BLOCK_SIZE)) dd if=/dev/urandom of=/var/test.dbf bs=
BLOCKSIZE))ddif=/dev/urandomof=/var/test.dbfbs=BLOCK_SIZE count=$COUNT;sync
Block sizes of 512b 1K 2K 4K 8K 16K 32K 64K 128K 256K 512K 1M 2M 4M 8M 16M 32M 64M
for BLOCK_SIZE in 512 1024 2048 4096 8192 16384 32768 65536 131072 262144 524288 1048576 2097152 4194304 8388608 16777216 33554432 67108864
do
echo 3>/proc/sys/vm/drop_caches
dd if=/var/test.dbf of=/dev/null bs=$BLOCK_SIZE;sync
done
测试结果:
Generating test file…
2048+0 records in
2048+0 records out
134217728 bytes transferred in 6.330 secs (21203432 bytes/sec)
262144+0 records in
262144+0 records out
134217728 bytes transferred in 1.271 secs (105600100 bytes/sec)
131072+0 records in
131072+0 records out
134217728 bytes transferred in 0.776 secs (172960989 bytes/sec)
65536+0 records in
65536+0 records out
134217728 bytes transferred in 0.482 secs (278460016 bytes/sec)
32768+0 records in
32768+0 records out
134217728 bytes transferred in 0.312 secs (430185025 bytes/sec)
16384+0 records in
16384+0 records out
134217728 bytes transferred in 0.236 secs (568719186 bytes/sec)
8192+0 records in
8192+0 records out
134217728 bytes transferred in 0.200 secs (671088640 bytes/sec)
4096+0 records in
4096+0 records out
134217728 bytes transferred in 0.185 secs (725501232 bytes/sec)
2048+0 records in
2048+0 records out
134217728 bytes transferred in 0.178 secs (754032179 bytes/sec)
1024+0 records in
1024+0 records out
134217728 bytes transferred in 0.154 secs (871543688 bytes/sec)
512+0 records in
512+0 records out
134217728 bytes transferred in 0.295 secs (454975349 bytes/sec)
256+0 records in
256+0 records out
134217728 bytes transferred in 0.351 secs (382386689 bytes/sec)
128+0 records in
128+0 records out
134217728 bytes transferred in 0.267 secs (502688119 bytes/sec)
64+0 records in
64+0 records out
134217728 bytes transferred in 0.232 secs (578524689 bytes/sec)
32+0 records in
32+0 records out
134217728 bytes transferred in 0.293 secs (458080982 bytes/sec)
16+0 records in
16+0 records out
134217728 bytes transferred in 0.255 secs (526344031 bytes/sec)
8+0 records in
8+0 records out
134217728 bytes transferred in 0.288 secs (466033777 bytes/sec)
4+0 records in
4+0 records out
134217728 bytes transferred in 0.250 secs (536870912 bytes/sec)
2+0 records in
2+0 records out
134217728 bytes transferred in 0.328 secs (409200390 bytes/sec)
根据上面结果看,不同的block size 读写速度不一样,每个硬件有一个最优的读写速度的size