Jmeter Summariser report及其可视化

Jmeter summariser report的设置在:bin/jmeter.properties

#---------------------------------------------------------------------------
# Summariser - Generate Summary Results - configuration (mainly applies to non-GUI mode)
#---------------------------------------------------------------------------
#
# Define the following property to automatically start a summariser with that name
# (applies to non-GUI mode only)
summariser.name=summary
#
# interval between summaries (in seconds) default 3 minutes
summariser.interval=180
#
# Write messages to log file
summariser.log=true
#
# Write messages to System.out
#summariser.out=true

以上设置每隔3分钟向jmeter.log中写入一行log
# Combined log file (for jmeter and jorphan)
log_file=jmeter.log

log的格式如下:

2017-11-21 15:49:14,389 INFO o.a.j.t.JMeterThread: Thread started: 线程组 1-100
2017-11-21 15:49:14,392 INFO o.a.j.p.h.s.HTTPHC4Impl: HTTP request retry count = 0
2017-11-21 15:49:14,408 INFO o.a.j.s.SampleResult: Note: Sample TimeStamps are START times
2017-11-21 15:49:14,411 INFO o.a.j.s.SampleResult: sampleresult.default.encoding is set to ISO-8859-1
2017-11-21 15:49:14,411 INFO o.a.j.s.SampleResult: sampleresult.useNanoTime=true
2017-11-21 15:49:14,411 INFO o.a.j.s.SampleResult: sampleresult.nanoThreadSleep=5000
2017-11-21 15:49:30,006 INFO o.a.j.r.Summariser: summary +   4857 in 00:00:16 =  308.1/s Avg:   258 Min:    22 Max:  7941 Err:     0 (0.00%) Active: 100 Started: 100 Finished: 0
2017-11-21 15:50:00,002 INFO o.a.j.r.Summariser: summary +  11529 in 00:00:30 =  384.3/s Avg:   271 Min:    30 Max: 21225 Err:     0 (0.00%) Active: 100 Started: 100 Finished: 0
2017-11-21 15:50:00,003 INFO o.a.j.r.Summariser: summary =  16386 in 00:00:46 =  358.1/s Avg:   267 Min:    22 Max: 21225 Err:     0 (0.00%)
2017-11-21 15:50:30,004 INFO o.a.j.r.Summariser: summary +  12104 in 00:00:30 =  403.5/s Avg:   233 Min:    43 Max: 15109 Err:    31 (0.26%) Active: 100 Started: 100 Finished: 0
2017-11-21 15:50:30,005 INFO o.a.j.r.Summariser: summary =  28490 in 00:01:16 =  376.0/s Avg:   252 Min:    22 Max: 21225 Err:    31 (0.11%)
2017-11-21 15:51:00,002 INFO o.a.j.r.Summariser: summary +  12112 in 00:00:30 =  403.8/s Avg:   268 Min:    44 Max: 84469 Err:    51 (0.42%) Active: 100 Started: 100 Finished: 0
2017-11-21 15:51:00,003 INFO o.a.j.r.Summariser: summary =  40602 in 00:01:46 =  383.9/s Avg:   257 Min:    22 Max: 84469 Err:    82 (0.20%)
2017-11-21 15:51:30,017 INFO o.a.j.r.Summariser: summary +  11994 in 00:00:30 =  399.6/s Avg:   245 Min:    40 Max: 17814 Err:    42 (0.35%) Active: 100 Started: 100 Finished: 0
2017-11-21 15:51:30,018 INFO o.a.j.r.Summariser: summary =  52596 in 00:02:16 =  387.4/s Avg:   254 Min:    22 Max: 84469 Err:   124 (0.24%)
2017-11-21 15:52:00,003 INFO o.a.j.r.Summariser: summary +  12153 in 00:00:30 =  405.3/s Avg:   250 Min:    34 Max: 13470 Err:    26 (0.21%) Active: 100 Started: 100 Finished: 0
2017-11-21 15:52:00,004 INFO o.a.j.r.Summariser: summary =  64749 in 00:02:46 =  390.6/s Avg:   254 Min:    22 Max: 84469 Err:   150 (0.23%)
2017-11-21 15:52:30,069 INFO o.a.j.r.Summariser: summary +  12318 in 00:00:30 =  409.7/s Avg:   234 Min:    40 Max: 14107 Err:    17 (0.14%) Active: 100 Started: 100 Finished: 0
2017-11-21 15:52:30,070 INFO o.a.j.r.Summariser: summary =  77067 in 00:03:16 =  393.5/s Avg:   250 Min:    22 Max: 84469 Err:   167 (0.22%)
2017-11-21 15:53:00,004 INFO o.a.j.r.Summariser: summary +  11864 in 00:00:30 =  396.3/s Avg:   253 Min:    39 Max: 25669 Err:    33 (0.28%) Active: 100 Started: 100 Finished: 0

summary +是这三分钟的数据,summary =是累计到当前时刻所有的数据

以黄色区域数据为例,4857是发出的请求数目,00:00:16是发出的时间, 308.1是每秒发出的请求,即吞吐量,Avg, Min, Max分别是平均响应时间,最小响应时间和最大响应时间,响应时间指的是从请求发出到收到响应的时间,Err后面跟的数据分别是错误数和错误比例。

对于summariser报告,可以通过写一个简单的脚本来解析并作图形化展示,下面是用python写的一个简单脚本,可以画平均时延和吞吐量,使用方法是

python summary.py test.log,下面是summary.py内容:

import matplotlib.pyplot as plt
import re
import sys

avgtime_data=[]
mintime_data=[]
maxtime_data=[]
throughput_data=[]

logfile=open(sys.argv[1])
try:
    while True:
        line=logfile.readline()
        if line=='':
            break
        if line.startswith('summary ='):
            result=re.split(r'\s+', line)
            avgtime_data.append(result[8])
            throughput=result[6]
            throughputvalue=throughput[:-2]
            throughput_data.append(throughputvalue)
finally:
    logfile.close()

plt.figure(figsize=(8,4))
plt.ylim(0,60)
plt.plot(avgtime_data,color="red",label="Avg ResponseTime (milliseconds)")
plt.plot(throughput_data,color="green",label="ThroughPut (/s)")
frame = plt.gca()
frame.axes.xaxis.set_ticklabels([])
plt.xlabel("Duration, 2013/06/25 16:30:00 -- 2013/06/28 6:00:00, about 60 hours")
plt.title("sundong Jmeter Test Report")
plt.legend()
plt.show()

注意里面用到了正则表达式,其实在log文件非常大的时候,每行都进行正则匹配,效率是很低的。分享下我们项目使用的切片方法写的rpc-server,效率要高出10几倍

import sys

reload(sys)
sys.setdefaultencoding('utf8')
import zerorpc


class RPCServer(object):
    def getLogData(self,filename):
        avgtime_data=[]
        throughput_data=[]
        tps_data=[]
        tpsput_data=[]
        with open(filename, 'r') as f:
            for line in f:
                if 'summary =' in line:
                    rs = line.split('Avg:')
                    avgtime_data.append(rs[1][0:6])
                    throughput_data.append(rs[0][-10:-3])

        return avgtime_data,throughput_data

s = zerorpc.Server(RPCServer())
s.bind("tcp://0.0.0.0:4242")
s.run()

通过rpc server获取jmeter master的log日志里的数据,应用通过rpc client进行调用

 

参考:

1、http://blog.csdn.net/just_lion/article/details/9209253

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值