ApacheBench 测试性能并使用 GnuPlot 绘制图表
转自:http://blog.csdn.net/fdipzone/article/details/18827069
ApacheBench
 测试性能并使用 GnuPlot 绘制图表
Apache Bench 是 web 性能测试工具,功能强大。但输出的结果只是数字形式,不容易看到数据的变化。因此,GnuPlot 的强大绘制功能正好可以弥补Apache Bench 这方面的不足。
关于 ApacheBench 的安装与使用可以参考我之前写的《ubuntu 中安装 apache ab 命令进行简单压力测试》
GnuPlot 下载地址:http://www.gnuplot.info/download.html
GnuPlot 文档地址:http://www.gnuplot.info/documentation.html
GnuPlot 的安装:
- tar zxvf gnuplot-4.6.4.tar.gz
- cd gnuplot-4.6.4
- ./configure
- sudo make && sudo make install
GnuPlot 的使用:
首先,使用 Apache Bench 测试性能,并将测试结果写入文件,我们分别对 http://localhost/index.php 进行三次性能测试。
- ab -n 500 -c 100 -g ./ab_500_100.dat http://localhost/index.php
- ab -n 500 -c 200 -g ./ab_500_200.dat http://localhost/index.php
- ab -n 500 -c 300 -g ./ab_500_300.dat http://localhost/index.php
参数 -g 表示将测试结果导出为一个 gnuplot 文件 ,三次测试的结果会保存在 ab_500_100.dat,ab_500_200.dat,ab_500_300.dat 中。
gnuplot 文件内容格式如下:
- starttime seconds ctime dtime ttime wait
- Mon Jan 27 21:03:02 2014 1390827782 89 503 592 28
- Mon Jan 27 21:03:02 2014 1390827782 84 591 676 24
- Mon Jan 27 21:03:02 2014 1390827782 93 616 710 24
- Mon Jan 27 21:03:02 2014 1390827782 94 628 722 28
- Mon Jan 27 21:03:02 2014 1390827782 84 741 824 26
- Mon Jan 27 21:03:02 2014 1390827782 84 741 825 26
- Mon Jan 27 21:03:02 2014 1390827782 101 725 826 23
- Mon Jan 27 21:03:02 2014 1390827782 124 707 831 80
- Mon Jan 27 21:03:02 2014 1390827782 204 629 833 28
- Mon Jan 27 21:03:02 2014 1390827782 95 741 836 26
- Mon Jan 27 21:03:02 2014 1390827782 96 743 838 50
- Mon Jan 27 21:03:02 2014 1390827782 96 744 840 40
- Mon Jan 27 21:03:02 2014 1390827782 109 773 883 36
- Mon Jan 27 21:03:02 2014 1390827782 109 774 883 37
- Mon Jan 27 21:03:02 2014 1390827782 153 765 918 51
- Mon Jan 27 21:03:02 2014 1390827782 141 778 919 76
- Mon Jan 27 21:03:02 2014 1390827782 115 814 929 28
- Mon Jan 27 21:03:02 2014 1390827782 103 831 934 23
- Mon Jan 27 21:03:02 2014 1390827782 103 831 934 23
- Mon Jan 27 21:03:02 2014 1390827782 108 831 939 36
- Mon Jan 27 21:03:02 2014 1390827782 115 825 940 64
- Mon Jan 27 21:03:02 2014 1390827782 162 783 945 87
- Mon Jan 27 21:03:02 2014 1390827782 119 831 950 32
- Mon Jan 27 21:03:02 2014 1390827782 108 844 952 15
- Mon Jan 27 21:03:02 2014 1390827782 128 830 958 32
- Mon Jan 27 21:03:02 2014 1390827782 128 831 958 35
- Mon Jan 27 21:03:02 2014 1390827782 108 856 964 87
- Mon Jan 27 21:03:02 2014 1390827782 123 843 967 15
- 后面省略。。
然后,根据导出的 gnuplot 文件绘制图表,绘制脚本如下:
- # 设定输出图片的格式
- set terminal png
- # 设定输出的图片文件名
- set output "ab_500.png"
- # 图表的标题
- set title "ab_500 ab -n 500 -c 100,200,300"
- # 设定图表的 X 轴和 Y 轴缩放比例(相当于调整图片的纵横比例,方形的不好看啊)
- set size 1,0.7
- # 设定以 Y 轴数据为基准绘制栅格(就是示例图表中的横向虚线)
- set grid y
- # X 轴标题
- set xlabel "request"
- # Y 轴标题
- set ylabel "response time (ms)"
- # 设定 plot 的数据文件,曲线风格和图例名称,以第九列数据 ttime 为基准数据绘图
- plot "ab_500_100.dat" using 9 smooth sbezier with lines title "conc per 100","ab_500_200.dat" using 9 smooth sbezier with lines title "conc per 200","ab_500_300.dat" using 9 smooth sbezier with lines title "conc per 300"
参数说明:
set size 1,0.7 缩放比例,前面是 X 轴,后面是 Y 轴, (0, 1] 的一个浮点数,1 为原始值
using 9 表示用哪一列数据绘图,数字是数据行按照空格或制表符分割的字段数字索引,从 1 开始
smooth sbezier plot 提供的一些数据填充算法以保证线条平滑度的,包含如下选项:smooth {unique | csplines | acsplines | bezier | sbezier},更详细解释请参考官方文档
with lines title "xxx" 这个会在右上角生成一个图例,用于区分什么颜色的线条是哪一项数据
生成的图表如下:
ApacheBench 测试性能并使用 GnuPlot 绘制图表的更多相关文章
- Pylot网站Web服务器性能和负载压力测试-适用Windows可绘制图表
		为了能够准确地评估网站服务器对网络流量的承受能力,我们一般会采取模拟网站用户访问,通过不断地增加并发数,延长访问时长,从而最终得出网站Web服务器的性能和负载能力.当然也可以通过Web压力测试,来完善 ... 
- DevExpress使用之ChartControl控件绘制图表(多坐标折线图、柱状图、饼状图)
		最近因为公司项目需要用到WinForm的DecExpress控件,在这里把一些使用方法总结一下. DevExpress中有一个专门用来绘制图表的插件ChartControl,可以绘制折线图.饼状图.柱 ... 
- iOS - Quartz 2D 第三方框架 Charts 绘制图表
		1.Charts 简介 使用第三方框架 Charts 绘制 iOS 图表.GitHub 源码 Charts Charts 是一款用于绘制图表的框架,可以绘制柱状图.折线图.K线图.饼状图等.Chart ... 
- iOS:使用贝塞尔曲线绘制图表(折线图、柱状图、饼状图)
		1.介绍: UIBezierPath :画贝塞尔曲线的path类 UIBezierPath定义 : 贝赛尔曲线的每一个顶点都有两个控制点,用于控制在该顶点两侧的曲线的弧度. 曲线的定义有四个点:起始点 ... 
- QCustomplot使用分享(九) 绘制图表-多功能游标
		目录 一.概述 二.效果图 三.源码讲解 1.源码结构 2.头文件 3.添加游标 4.监测移动 5.移动游标 6.其他函数 四.测试方式 1.测试工程 2.测试文件 3.测试代码 五.相关文章 六.总 ... 
- WinForm DevExpress使用之ChartControl控件绘制图表一——基础
		最近因为公司项目需要用到WinForm的DecExpress控件,在这里把一些使用方法总结一下. DevExpress中有一个专门用来绘制图表的插件ChartControl,可以绘制折线图.饼状图.柱 ... 
- 使用D3绘制图表(7)--饼状图
		这次是绘制饼状图,也是这一次使用D3绘制图表的最后一篇,大家可以从其他地方深入学习D3绘制图表,也可以直接查看D3的API进行学习,本次绘制饼状图的数据跟之前的卸载数组里面的不一样,这一次是使用d3的 ... 
- 网页绘制图表 Google Charts with JavaScript #2 ....与ASP.NET网页结合 (ClientScriptManager.RegisterStartupScript 方法)
		此为文章备份,原文出处(我的网站) 网页绘制图表 Google Charts with JavaScript #2 ....与ASP.NET网页结合 (ClientScriptManager.Regi ... 
- 网页绘制图表 Google Charts with JavaScript #1....好强、好简单啊!
		此为文章备份,原文出处(我的网站) 网页绘制图表 Google Charts with JavaScript....好强.好简单啊!#1 http://www.dotblogs.com.tw/mis2 ... 
随机推荐
- CentOS 6.9安装过程
			下载: https://wiki.centos.org/Download 安装过程: 分区方案一: 以下为大概的分区步骤,根据实际需要进行分配: 最终分区的配置大小如下所示: 推荐更详细的分区方案,参 ... 
- LNMP一键安装包 V1.1 公布
			LNMP一键安装包 是一个用Linux Shell编写的能够为CentOS/RadHat.Debian/Ubuntu VPS(VDS)或独立主机安装LNMP(Nginx.MySQL/MariaDB.P ... 
- 【待解决】maven创建web报Cannot read lifecycle mapping metadata for artifact org.apache.maven.plugins
			Cannot read lifecycle mapping metadata for artifact org.apache.maven.plugins:maven-war-plugin:maven- ... 
- phpfpm的配置
			1.php中fastcgi和php-fpm是什么东西 最近在研究和学习PHP的性能方面的知识,看到了factcgi以及php-fpm,发现我对他们是少之又少的理解,可以说几乎是一无所知,想想还是蛮可怕 ... 
- Could not read from remote repository.
			今天换新电脑,忘了配置git环境,就去gitserver上代替码.然后一直报错,后来就又一次配置了git环境.步骤例如以下 damingwuage:Desktop damingwuage$ ssh-k ... 
- oc3--类方法1
			// // main.m // 第一个OC类-方法 #import <Foundation/Foundation.h> /* C语言中函数分为声明和实现,OC中定义类, 就是在写类的声明和 ... 
- 【POJ 3071】 Football
			[题目链接] http://poj.org/problem?id=3071 [算法] 概率DP f[i][j]表示第j支队伍进入第i轮的概率,转移比较显然 [代码] #include <algo ... 
- C++_class_powerpoint_1.1
			Types and Declarations Boolean Type bool type – boolean , logic type bool literal – true, falseint a ... 
- Linux Shell Scripting Cookbook 读书笔记 6
			wget,curl, tar, rsync wget ftp://example.com/somefile.img -t 5 -O download.img -o log -t表示重试的次数 -O指定 ... 
- Solr.NET快速入门(九)【二进制文档上传】【完】
			二进制文档上传 SolrNet支持Solr"提取"功能(a.k.a. Solr"Cell")从二进制文档格式(如Word,PDF等)索引数据. 这里有一个简单的 ... 
 
			
		