Jmeter Summariser report及其可视化

来源:互联网 发布:狼居胥山在哪 知乎 编辑:程序博客网 时间:2024/06/07 05:39

Jmeter在做性能测试的时候,可能会run很长时间,这样产生的log会非常大,跑过一次72小时的测试,log达到了6G!,这样分析起来会比较麻烦,JMeter还提供了summariser result report,就是在每隔一段时间打一行log,这样log就会大大减小。

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 minutessummariser.interval=180## Write messages to log filesummariser.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的格式如下:

Creating summariser <summary>Created the tree successfully using /opt/JMeter/TestPlan/test.jmxStarting the test @ Tue Jun 25 16:22:12 CST 2013 (1372148532713)Waiting for possible shutdown message on port 4445summary +   2075 in   107s =   19.4/s Avg:    51 Min:    12 Max:  2318 Err:     0 (0.00%) Active: 1 Started: 1 Finished: 0summary +   3753 in   180s =   20.8/s Avg:    47 Min:    12 Max:   849 Err:     0 (0.00%) Active: 1 Started: 1 Finished: 0summary =   5828 in   287s =   20.3/s Avg:    49 Min:    12 Max:  2318 Err:     0 (0.00%)summary +   3864 in   180s =   21.4/s Avg:    46 Min:    11 Max:   634 Err:     0 (0.00%) Active: 1 Started: 1 Finished: 0summary =   9692 in   467s =   20.7/s Avg:    48 Min:    11 Max:  2318 Err:     0 (0.00%)summary +   3847 in   180s =   21.4/s Avg:    46 Min:    11 Max:   697 Err:     0 (0.00%) Active: 1 Started: 1 Finished: 0summary =  13539 in   647s =   20.9/s Avg:    47 Min:    11 Max:  2318 Err:     0 (0.00%)

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

以第三行数据为例,5828是发出的请求数目,287s是时间, 20.3是每秒发出的请求,即吞吐量,Avg, Min, Max分别是平均响应时间,最小响应时间和最大响应时间,响应时间指的是从请求发出到收到响应的时间,Err后面跟的数据分别是错误数和错误比例。

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

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

import matplotlib.pyplot as pltimport reimport sysavgtime_data=[]mintime_data=[]maxtime_data=[]throughput_data=[]logfile=open(sys.argv[1])try:    while True:line=logfile.readline()if line=='':breakif 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()