美文网首页
性能对比报告记录

性能对比报告记录

作者: LeslieFind | 来源:发表于2021-01-06 23:18 被阅读0次

背景:

基于流水线的触发代码和定时执行的功能,考虑能够加上发布前的性能对比报告给开发更好,最终呈现出图表更加直观

思路:

一、首先构建jmeter的基础镜像jmeter-base(运行时需2个容器,一个执行master分支环境,一个执行dev分支环境)
二、在流水线构建两套环境,master和dev
三、jmeter-base中shell脚本,需实现的功能:

1、根据传入的branch或ip或hulk平台的开放接口获取请求的ip
2、有了ip后,传入持续时长,生成3分不同的jmx脚本,比如:list_thread_num_10.jmx的压测脚本
3、分别执行这些脚本,生成对应的报告文件
4、从报告中获取到压测数据,存入变量中
5、调用自定义接口,新增记录;

数据库中参数大致如下:

1、branch:分支
2、type:类型(先=1,为指定3种不同线程数;后续可以指定开始线程和结束线程数及区间,还有按照资源维度等)
3、thread_num:并发数
4、tps:
5、resp_time:
6、online:是否是线上版本,考虑可以跑一下线上版本,备用
7、during:持续时间
8、tps_exp:map/list(方便生成图)
9、resp_time_exp:map/list(方便生成图)
10、err_rate:错误率

自定义接口功能:

1、新增记录
2、获取最近3条master的数据(onlineList):用于日常开发合分支diff展示
3、获取dev和master的数据(testList):用于功能测试结束,上线之前diff展示,性能测试报告

=============================================================================
后续又使用locust
locust统计脚本思路:

#1、执行脚本,结束后
#2、解析:ldtest_stats.csv(总概数据):
#    grep "Aggregated" ldtest_stats.csv |awk -F , '{print $3,$4,$6,$10}'
#    grep "Aggregated" ldtest_stats.csv |awk -F , '{printf ("%.2f\n",$6)}' ——保留2位小数
#    结果:6118 90 193.21251854796148 51.00158406755608
#    ($3:总事务数,$4:错误数,$6:平均响应时长,$10:rps)
#    ------------------------------------------------
#    总事务数:grep "Aggregated" ldtest_stats.csv |awk -F , '{print $3}'——6118
#    错误数:grep "Aggregated" ldtest_stats.csv |awk -F , '{print $4}'——90
#    平均响应时长:grep "Aggregated" ldtest_stats.csv |awk -F , '{printf ("%.2f\n",$6)}'——193.21
#    rps每秒请求数:grep "Aggregated" ldtest_stats.csv |awk -F , '{printf ("%.2f\n",$10)}'——51.00
#    *额外计算错误率:grep "Aggregated" ldtest_stats.csv |awk -F , '{printf ("%.2f\n",$4/$3)}'——0.01
#    --------------------------------------------------------------------------------------------
#3、解析:ldtest_stats_history.csv
#    1、开始时间:sed -n 2p ldtest_stats_history.csv | cut -d ',' -f1
#    2、结束时间:sed -n '$p' ldtest_stats_history.csv | cut -d ',' -f1
#    3、时间与rps: awk -F , '{print $1,$5}' ldtest_stats_history.csv
#    4、时间与rt:awk -F , '{print $1,$21}' ldtest_stats_history.csv

locust统计脚本:

#!/bin/bash

# nohup locust -f locustfile.py --host=http://10.209.141.48 -u 10 -r 10 -t 120 --headless --csv ldtest --logfile testlogs -L debug  > debug.file 2>&1 &
# nohup locust -f locustfile.py --host=http://10.209.141.48 -u 2 -r 2 -t 20 --headless --csv ldtest --logfile testlogs -L debug > debug.file 2>&1 &

#1、执行脚本,结束后
# 6个参数:例:“locustfile.py http://10.209.141.48 2 2 20 ldtest testlogs”

if [[ $1 = "help" ]] || [[ $1 = "-h" ]]; then
    echo "test script and statistics the test's results"
    echo "\$1: locustfile"
    echo "\$2: serverHost"
    echo "\$3: threadNum"
    echo "\$4: threadNumPerSecond"
    echo "\$5: duration"
    echo "\$6: logfile"
else
    currentTime=`date "+%m%d%H%M"`
    # locust脚本
    locustfile=$1
    echo "***locustfile is: $1"

    # 服务端host
    serverHost=$2
    echo "***serverHost is: $2"

    # 并行数,虚拟用户数
    threadNum=$3
    echo "***threadNum is: $3"

    # 每s启动线程数
    threadNumPerSecond=$4
    echo "***threadNumPerSecond is: $4"

    # 持续时长
    duration=$5
    echo "***duration is: $5"

    #csvPrefix
    csvPrefix=testCsvData-$currentTime
    echo "***csvPrefix is: $csvPrefix"

    #logfile
    logfile=$6
    echo "***logfile is: $6"

    # 压测分支
#    若无,存master
    branch=$7


    # is_online
#    若无存0
    isOnline=$8
    
    if [ $# -lt 6 ]; then
        echo "ERROR====> the params must six!!!"
        exit 1;
    fi

    nohup locust -f $locustfile --host=$serverHost -u $threadNum -r $threadNumPerSecond -t $duration --headless --csv $csvPrefix --logfile $logfile -L debug > debug.file 2>&1 &
    echo "===locust commond is: nohup locust -f $locustfile --host=$serverHost -u $threadNum -r $threadNumPerSecond -t $duration --headless --csv $csvPrefix --logfile $logfile -L debug > debug.file 2>&1 &"

    locustProcess=`ps -ef | grep "locust -f locustfile.py" | grep -v grep | wc -l`
    while [ $locustProcess -gt 0 ]
    do
      locustProcess=`ps -ef | grep "locust -f locustfile.py" | grep -v grep | wc -l`
    done

    echo "===locust commond is end==="

    #================statistics==========================

    # 文件名称
    statsCsv=$csvPrefix"_stats.csv"
    echo "statsCsv file is: $statsCsv"

    statsHistoryCsv=$csvPrefix"_stats_history.csv"
    echo "statsHistoryCsv file is: $statsHistoryCsv"

    # 总事务数
    sumReq=`grep "Aggregated" $statsCsv |awk -F , '{print $3}'`
    echo "---->sumReq is: $sumReq"

    #平均响应时间
    avgRt=`grep "Aggregated" $statsCsv |awk -F , '{printf ("%.2f\n",$6)}'`
    echo "---->avgRt is: $avgRt"

    #tps
    tps=`grep "Aggregated" $statsCsv |awk -F , '{printf ("%.2f\n",$10)}'`
    echo "---->tps is: $tps"

    # 错误数
    errNum=`grep "Aggregated" $statsCsv |awk -F , '{print $4}'`
    echo "---->errNum is: $errNum"

    # 错误百分比
    errPerc=`grep "Aggregated" $statsCsv |awk -F , '{printf ("%.2f\n",$4/$3)}'`
    echo "---->errPerc is: $errPerc"

    # 开始时间
    creeateTime=`sed -n 2p $statsHistoryCsv | cut -d ',' -f1`
    echo "creeateTime is:$creeateTime"

    # 结束时间
    endTime=`sed -n '$p' $statsHistoryCsv | cut -d ',' -f1`
    echo "endTime is: $endTime"

#    ********************计算时间对应的***********************************

    declare -A timeRpsData
    declare -A timeRtData

    # 先取出时间
    timeList=`grep -v "Timestamp" $statsHistoryCsv | awk -F , '{print $1}'`

    # 取出rps
    rpsList=`grep -v "Timestamp" $statsHistoryCsv | awk -F , '{print $5}'`

    # 取出rt
    rtList=`grep -v "Timestamp" $statsHistoryCsv | awk -F , '{print $21}'`

    for t in $timeList;
    do
      # 取时间和rps对应关系
      timeRpsData[$t]=`grep "$t" $statsHistoryCsv | awk -F , '{printf ("%.2f\n", $5)}'`

      # 取时间和rt对应关系
      timeRtData[$t]=`grep "$t" $statsHistoryCsv | awk -F , '{printf ("%.2f\n", $21)}'`

    done

#    for key in "${!timeRpsData[@]}";
#    do
#      echo "$key------>${timeRpsData[$key]}"
#    done
#
#    for key in "${!timeRtData[@]}";
#    do
#      echo "$key==========>${timeRtData[$key]}"
#    done

    #=============================数据存库==============================================================================
    

fi

相关文章

  • 性能对比报告记录

    背景: 基于流水线的触发代码和定时执行的功能,考虑能够加上发布前的性能对比报告给开发更好,最终呈现出图表更加直观 ...

  • 大师级:区块链成熟度评测报告

    区块链成熟度评测报告(1)——功能性对比 区块链成熟度评测报告(2)——性能效率、安全性对比 区块链成熟度评测报告...

  • 五款主流 Linux 发行版性能对比,稳而不强?

    2018 即将结束,年末正是各种基准测试对比轮番出炉的时候,通过这些报告,我们可以看到 Linux 性能的各个方面...

  • 汇天下EA~摇钱树系列

    摇钱树交易系统实战性能报告:报告说明:数据采集2019年8月1日~11月12日实际运行交易记录统计结果,2000美...

  • objectbox使用及对比

    一、数据库对比:1.特性对比 2.性能对比: 性能对比使用了官方出的对比demo: 二、各数据库使用了解1.obj...

  • RedisJson性能碾压ES和MongoDB

    一、RedisJson性能测试报告结论 近期官网给出了RedisJson(RedisSearch)的性能测试报告,...

  • 外卖接口压力测试报告

    外卖接口性能测试报告 ​ ​ 1 概述 1.1 目的 本测试报告为外卖接口的性能测试报告,目的在于总结测试阶段的测...

  • Redis VS Memcache 区别

    网络IO模型 性能对比:(占用的核数,线程数,网络模型) 性能对比:由于Redis只使用单核,而Memcached...

  • 关于Python-docx操作excel的一些记录

    背景 最近在做客户端性能测试的提效工作,会把当前版本的性能数据与上个版本的性能数据进行对比,然后把对比结论以及数据...

  • 如何做性能测试

    偶然间看到了阿里中间件Dubbo的性能测试报告,我觉得这份性能测试报告让人觉得做这性能测试的人根本不懂性能测试,我...

网友评论

      本文标题:性能对比报告记录

      本文链接:https://www.haomeiwen.com/subject/izcaoktx.html