首页 > 技术知识 > 正文

【海思应用篇】-(10)U盘测速

挂载U盘

mount -t vfat /dev/sda1 /var/

测试写入100MB速度

sync;time dd if=/dev/zero of=/var/largefile bs=10k count=10240;time sync

测试读取100MB速度 (清除缓存)

sync;echo 3 > /proc/sys/vm/drop_caches;time dd if=/var/largefile of=/dev/null bs=10k

上述测试方法就相对比较准确!

写入100MB时,先刷新flash后,才测量dd命令生成100MB到缓存(同时也有部分正在写入flash)的时间Tdd,最后测量sync的时间Tsync,这个时间即为从缓存写到U盘的时间。平均写入速度为:100MB/(Tdd+Tsync)。

测量读取速度时,亦先sync把缓存中的杂数据写写进flash,并且清除缓存。最后才记录dd命令从U盘写入RAM的时间Tdd,因为/dev/null为tmpfs,没必要计算Tsync,平均读取速度为:100MB/Tdd。

另外,time命令算出的时间要使用real对应的值。

sync;time dd if=/dev/zero of=/var/largefile bs=10k count=10240;time sync

10240+0 records in

10240+0 records out

104857600 bytes (100.0MB) copied, 3.290081 seconds, 30.4MB/s

real 0m 3.29s

user 0m 0.00s

sys 0m 1.12s

real 0m 9.02s

user 0m 0.00s

sys 0m 0.00s

~ # sync;echo 3 > /proc/sys/vm/drop_caches;time dd if=/var/largefile of=/dev/null bs=10k

10240+0 records in

10240+0 records out

104857600 bytes (100.0MB) copied, 4.203014 seconds, 23.8MB/s

real 0m 4.20s

user 0m 0.02s

sys 0m 0.45s

猜你喜欢