mysql fio测试_fio测试和分析 - 认真即可的个人空间 - OSCHINA - 中文开源技术交流社区...

fio测试脚本

#!/bin/bash

set -e

ioengine="libaio"

iodepth=128

direct=1

fsync=1

runtime=600

size="10G"

mntdir="/mnt/fio-data/"

mkdir -p /mnt/fio-data

mount /dev/vdb /mnt/fio-data || true

for m in seq rand

do

prefix=""

if [ "$m" == "seq" ] ; then

bs="1024K"

else

bs="4K"

prefix="rand"

fi

for op in read write

do

cat <$mntdir/fio-$m-$op.fio

[global]

fsync=$fsync

name=fio-$m-$op

filename=fio-$m-$op

rw=$prefix$op

bs=$bs

direct=$direct

numjobs=1

time_based=1

runtime=$runtime

[file1]

size=$size

ioengine=$ioengine

iodepth=$iodepth

EOF

done

done

docker rm -f $(docker ps -a -q) >/dev/null 2>&1|| true

echo "test case: $c"

outdir=`pwd`/result-`date "+%Y%m%d%H%M"`

mkdir -p $outdir

for p in `ls -1 $mntdir/*.fio`

do

f=`basename $p`

echo 3 > /proc/sys/vm/drop_caches

cmd="docker run --name=$f -v $mntdir:/tmp/fio-data -e JOBFILES=/tmp/fio-data/$f \

clusterhq/fiotools-aio bash /opt/run.sh \

| tee -a $outdir/$f.log"

echo $cmd

eval $cmd

sleep 1

done

提取iops和bw

#!/usr/bin/python2.7

import os

import re

from pathlib import Path

def get_perf(file, type, perf):

m = re.compile('\s*{}\s*: .* {}=(\d+)'.format(type, perf))

with open(file) as f:

for line in f.readlines():

g = m.search(line)

if g is not None and len(g.groups()) == 1:

return g.groups()[0]

raise Exception("{} {} not found".format(type, perf))

def parse(dir, perf):

data = []

perf_type = 'rand' if perf == 'iops' else 'seq'

dirs = Path(dir).glob('result-*/')

for d in dirs:

f = os.path.join(d.name, 'fio-%s-read.fio.log' % perf_type)

read = get_perf(f, "read", perf)

f = os.path.join(d.name, 'fio-%s-write.fio.log' % perf_type)

write = get_perf(f, "write", perf)

data.append((read, write))

return data

if __name__ == '__main__':

cwd = os.path.dirname(os.path.realpath(__file__))

data = parse(cwd, "iops")

with open("iops.txt", "w") as f:

i = 1

for l in data:

f.write('{} {} {}\n'.format(i, l[0], l[1]))

i = i + 1

data = parse(cwd, "bw")

with open("bw.txt", "w") as f:

i = 1

for l in data:

f.write('{} {} {}\n'.format(i, l[0], l[1]))

i = i + 1

gunplot画图

iops

#!/bin/bash

data=iops.txt

pic=iops.png

/usr/local/bin/gnuplot << EOF

set autoscale # scale axes automatically

set xtic 1 # set xtics automatically

set ytic 1000 # set ytics automatically

set title "IOPS over Time"

set xlabel "samples over time"

set ylabel "iops"

set grid

set term png medium

set term png size 953, 620

set key box top left

set output "$pic"

plot "$data" using 1:2 title "read" with linespoints, \

"$data" using 1:3 title "write" with linespoints

quit

EOF

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值