MySQL/Mariadb基准测试工具-tpcc-mysql使用3

tpcc-mysql 是percona基于TPCC标准的mysql实现,专用于mysql基准测试。在上一篇说到tpcc-mysql 的使用,本篇继续说它的使用其他方面,如分析和绘图等。

5.生成图表

1) 生成分析数据

首先写一个脚本获取数据源:

# cat tpcc-output-analyze.sh
#!/bin/sh
TIMESLOT=1
if [ -n "$2" ]
then
TIMESLOT=$2
fi
cat $1 | grep -v HY000 | grep -v payment | grep -v neword | awk -v timeslot=$TIMESLOT 
'BEGIN { FS="[,():]"; s=0; cntr=0; aggr=0 } /MEASURING START/ { s=1} /STOPPING THREADS/ {s=0} /0/ { if (s==1) { cntr++; aggr+=$2; } if ( cntr==timeslot ) { printf ("%d %3d\n",$1,(aggr/timeslot)) ; cntr=0; aggr=0 } }'

这个脚本就是对 tpcc-output-nobinlog 的第一列与第二列进行运算。

#./tpcc-output-analyze.sh tpcc-output-nobinlog > tpcc-graphic-data.txt

在tpcc-mysql目录scripts中有个脚本analyze.sh和以上脚本类似。

2)绘图

绘图过程:

#cat log.conf
set terminal gif small size 480,360 #指定输出成gif图片,且图片大小为550×25
set output "tcpp.gif"   #指定输出gif图片的文件名
set title "MySQL Performance"   #图片标题
set style data lines    #显示网格
set xlabel "Time/s" #X轴标题
set ylabel "Data"   #Y轴标题
set grid    #显示网格
plot \
"tpcc-graphic-data.txt" using 1:2 title "Total throughput" with lines #从tpcc-graphic-data.txt文件中读取第一列和第二列作为X轴和Y轴数据,示例名"Total throughput"

运行生成tcpp.gif:

#cat log.conf | gnuplot

示例:
这里写图片描述

补充gnuplot绘图,详细可以google下
例如得到文件类似如下:

11:23 28 15
11:24 10 7
11:25 224 37 13
11:26 470 192
11:27 344 187 1
11:28 441 77 2
11:29 419 8

然后创建gnuplot.conf如下:

set terminal png xFFEEDD size 2048,512
set output "log.png"
set autoscale
set xdata time
set timefmt "%H:%M"
set format x "%H:%M"
set xtics 10
set mxtics 4
set style data lines
set datafile missing "0″
set xlabel "time per day"
set ylabel "purge"
set title "DPD expires"
set grid
plot "log" using 1:2 title "html/min","log" using 1:3 title "js/min","log" using 1:4 title "css/min"

运行cat gnuplot.conf|gnuplot就得到log.png了,如下:
这里写图片描述

百度文库中由网友【819347304】,上传的【tpcc-mysql安装及Mysql压力测试】中描述的分析和绘图方法如下:

分析测试数据

分析测试结果,并保存到tpcc.ana文件中
shtpcc-analyze.sh tpcc.out>tpcc.ana
正常情况下会进行多个测试,则需要对每个结果进行分析,并产生相应的分析结果
测试分类:同配置,同线程数,不同测试时间;同配置,不同线程数;不同配置

sh tpcc-analyze.sh tpcc.out.1 > tpcc.ana.1 
sh tpcc-analyze.sh tpcc.out.2 > tpcc.ana.2
sh tpcc-analyze.sh tpcc.out.3 > tpcc.ana.3
#合并分析结果(此出为2个)
paste tpcc.ana.1 tpcc.ana.2 > tpcc-graph.data

绘图(使用分析结果)

绘图时遇到的错误:

Could not find / open font when opening font "arial" , using internal non-scalable font 
gnuplot > plot datafile using 1:2 title " Test Result 1:XXX " with lines , datafile using 3:4 title " Test Result 2:XXX " with lines axes x1y1 
line 0 : warning : Skipping data file with no valid points 

解决办法: 从错误提示可以看出:缺少“arial”的字体支持,这需要安装windows通用字体,下载地址:http://www.my-guides.net/en/images/stories/fedora12/
安装:

#rpm-ivh msttcore-fonts-2.0-3.noarch.rpm 

之后,在msttcore的路径下即可找到ariali.ttf,猜想这应该就是所要的字体库了吧!

设置临时环境变量:

#export GDFONTPATH="/usr/share/fonts/msttcore"
#export GNUPLOT_DEFAULT_GDFONT="arial" 

检查环境变量是否设置成功:

#echo $GDFONTPATH
/usr/share/fonts/msttcore 
#echo $GNUPLOT_DEFAULT_GDFON
Tarial 

gnuplot使用说明

./tpcc-graph-build.shtpcc-graph.datatpcc-graph.jpg

如果不适用分析结果绘图,可直接适用./tpcc-graph-build.shtpcc.outtpcc.jpg将结果直接绘图出来

附shell脚本
tpcc-analyze.sh

TIMESLOT=1 
if [ -n \"$2\" ] 
then 
TIMESLOT=$2 
echo “Defined $2″ 
fi 
cat $1 | grep -v HY000 | grep -v payment | grep -v neword | awk -v timeslot=$TIMESLOT 'BEGIN { FS=”[,():]“; s=0; cntr=0; aggr=0 } /MEASURING START/ { s=1} /STOPPING THREADS/ {s=0} /0/ { if (s==1) { cntr++; aggr+=$2; } if ( cntr==timeslot ) { printf (“%d %3d\\n”,$1,(aggr/’$TIMESLOT’)) ; cntr=0; aggr=0 } }' 

tpcc-graph-build.sh

#!/bin/bash 
### goto user homedir and remove previous file 
rm -f$2′ 
gnuplot << EOP 
### set data source file 
datafile = ‘$1### set graph type and size 
set terminal jpeg size 640,480 
### set titles 
set grid x y 
set xlabel “Time (sec)” 
set ylabel “Transactions” 
### set output filename 
set output ‘$2### build graph 
# plot datafile with lines 
plot datafile using 1:2 title “Test Result 1: XXX ” with lines, \ 
    datafile using 3:4 title “Test Result 2: XXX ” with lines axes x1y1 
EOP 

遗留问题

参考

感谢以下大神,您的分享使我少走弯路。
[1]志在千裏-ChinaUnix: http://blog.chinaunix.net/uid-25266990-id-4080103.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值