一.工具下載下傳并編譯
1.wget http://brick.kernel.dk/snaps/fio-2.2.5.tar.gz
2.tar -zxvf fio-2.2.5.tar.gz
3.cd fio-2.2.5
4.因為我們要在android中運作,是以我們需要安裝交叉編譯工具
sudo apt-get install gcc-arm-linux-gnueabihf
5.編譯代碼,指定arm運作平台,編譯工具為arm-linux-gnueabihf-gcc,并且需要靜态編譯
./configure --cpu=arm --cc=arm-linux-gnueabihf-gcc --build-static --disable-shm
make
6.編譯完成後會生成fio可執行程式我們把它push到手機中
adb push fio /system/bin/
二.測試指令
随機讀
fio -filename=/data/test_rand -direct=1 -iodepth 1 -thread -rw=randread -ioengine=psync -bs=1M -size=1G -numjobs=5 -group_reporting -name=mytest
随機寫
fio -filename=/data/test_rand -direct=1 -iodepth 1 -thread -rw=randwrite -ioengine=psync -bs=1M -size=1G -numjobs=5 -group_reporting -name=mytest
順序寫
fio -filename=/data/test_ordwrite -direct=1 -iodepth 1 -thread -rw=write -ioengine=psync -bs=1M -size=1G -numjobs=5 -group_reporting -name=mytest
順序讀
fio -filename=/data/test_ordread -direct=1 -iodepth 1 -thread -rw=read -ioengine=psync -bs=1M -size=1G -numjobs=5 -group_reporting -name=mytest
三.日志解析
fio: terminating on signal 2
mytest: (groupid=0, jobs=10): err= 0: pid=11806: Mon Oct 19 08:44:24 2020
read : io=127488KB, bw=154157KB/s, iops=9634, runt= 827msec
clat (usec): min=237, max=18944, avg=1021.95, stdev=1466.30
lat (usec): min=237, max=18945, avg=1022.66, stdev=1466.33
clat percentiles (usec):
| 1.00th=[ 298], 5.00th=[ 350], 10.00th=[ 390], 20.00th=[ 498],
| 30.00th=[ 596], 40.00th=[ 660], 50.00th=[ 708], 60.00th=[ 756],
| 70.00th=[ 804], 80.00th=[ 884], 90.00th=[ 1384], 95.00th=[ 2480],
| 99.00th=[ 9536], 99.50th=[10688], 99.90th=[11840], 99.95th=[11968],
| 99.99th=[19072]
bw (KB /s): min=14501, max=17088, per=10.21%, avg=15735.10, stdev=783.17
lat (usec) : 250=0.04%, 500=20.17%, 750=38.94%, 1000=27.16%
lat (msec) : 2=5.52%, 4=5.10%, 10=2.27%, 20=0.80%
cpu : usr=1.00%, sys=17.40%, ctx=9100, majf=0, minf=40
IO depths : 1=100.0%, 2=0.0%, 4=0.0%, 8=0.0%, 16=0.0%, 32=0.0%, >=64=0.0%
submit : 0=0.0%, 4=100.0%, 8=0.0%, 16=0.0%, 32=0.0%, 64=0.0%, >=64=0.0%
complete : 0=0.0%, 4=100.0%, 8=0.0%, 16=0.0%, 32=0.0%, 64=0.0%, >=64=0.0%
issued : total=r=7968/w=0/d=0, short=r=0/w=0/d=0, drop=r=0/w=0/d=0
latency : target=0, window=0, percentile=100.00%, depth=1
Run status group 0 (all jobs):
READ: io=127488KB, aggrb=154157KB/s, minb=154157KB/s, maxb=154157KB/s, mint=827msec, maxt=827msec
Disk stats (read/write):
dm-0: ios=7705/188, merge=0/0, ticks=6370/35190, in_queue=50050, util=92.82%, aggrios=7968/290, aggrmerge=0/2, aggrticks=6360/73220, aggrin_queue=95720, aggrutil=91.97%
sda: ios=7968/290, merge=0/2, ticks=6360/73220, in_queue=95720, util=91.97%
本次度平均速度為154157KB/s,耗時為827msec
四.配合腳本做性能測試
五.問題彙總
運作報錯1:
xxxx:/ # fio -filename=/tmp/test_randread -direct=1 -iodepth 1 -thread -rw=randread -ioengine=psync -bs=16k -size=30G -numjobs=10 -runtime=600 -group_reporting -name=mytest
shmget: Function not implemented
error: failed to setup shm segment
指的編譯環境時需要加上:--disable-shm
./configure --cpu=arm --cc=arm-linux-gnueabihf-gcc --build-static --disable-shm