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的使用:

首先,使用ApacheBench 测试性能,并将测试结果写入文件,我们分别对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
后面省略。。

本栏目更多精彩内容:http://www.bianceng.cnhttp://www.bianceng.cn/webkf/tools/

然后,根据导出的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" 这个会再右上角生成一个图例,用于区分什么颜色的线条是哪一项数据

生成的图表如下:

以上是小编为您精心准备的的内容,在的博客、问答、公众号、人物、课程等栏目也有的相关内容,欢迎继续使用右上角搜索按钮进行搜索数据
, http500
, gnuplot 绘图
, libsvm gnuplot
, 500
, vpn 741
, ab测试
, y轴分割线
, 2014
, apachebench
, Lesson03_02
, Lesson02_03
, Lesson02_02
gnuplot
apachebench、apachebench下载、apachebench windows、apachebench下载安装、apachebench 官方下载,以便于您获取更多的相关知识。

时间: 2024-07-29 00:20:04

ApacheBench如何测试性能并使用GnuPlot绘制图表的相关文章

pacheBench测试性能并使用GnuPlot绘制图表

Apache Bench 是web性能测试工具,功能强大.但输出的结果只是数字形式,不容易看到数据的变化.因此,GnuPlot的强大绘制功能正好可以弥补Apache Bench这方面的不足. 关于ApacheBench的安装与使用可以参考我之前写的<ubuntu中安装apache ab命令进行简单压力测试> GnuPlot 下载地址:http://www.gnuplot.info/download.html GnuPlot 文档地址:http://www.gnuplot.info/docume

linux中gnuplot绘制性能监控图使用

 一.安装 目前的最新版为4.6.5,这里不再列出源码包的方式进行安装,因为常用的linux系统源里都有该包:  代码如下 复制代码 //centos/redhat等rpm包安装 yum -y install gnuplot //ubuntu/debian等 apt安装 sudo apt-get install gnuplot 二.使用及示例 gnuplot有两种绘图方式,一种是交互式,一种是直接配置好相关参数直接运行.(这点和python相似) 交互式方式的如果想直接将图形展示,需要x11终端

编写Bash Shell通过gnuplot绘制系统性能数据图的方法

  这篇文章主要介绍了编写Bash Shell通过gnuplot绘制系统性能数据图的方法,做到可视化数据收集,需要的朋友可以参考下 使用步骤: 1.设置一个定时任何 执行getperf.sh,采集性能数据 2.将采集到性能数据文件,如:192.168.1.1.tar.gz 解压 3.将性能分析的脚步performance_analyse.sh 放到解压后的目录中 4.安装gnuplot程序(这里下载) 5.将字体文件夹,拷贝到/usr/share/fonts/目录 6.直接运行 bash per

Android 界面的性能优化 —— 减少过度绘制

本文讲的是Android 界面的性能优化 -- 减少过度绘制, 你有了一个很棒的灵感,并且把它制作成了一个应用程序发布到了网上.但是,现在你听到了来自用户的抱怨,例如这个应用程序运行起来很慢有卡顿的感觉并且太难使用.. 有一个简单的解决方法是,你可以使用 GPU Overdraw 工具来改进应用程序的渲染时间. 什么是过度绘制? 过度绘制发生在每一次应用程序要求系统在某些界面上再绘制一些界面的时候.这个 Debug GPU Overdraw 工具可以在屏幕最上层叠加上一些颜色,它显示出一个像素点

java 性能测试-Java程序测试性能发现执行时间随着循环次数会明显降低

问题描述 Java程序测试性能发现执行时间随着循环次数会明显降低 今天用java写了一段算法,主要涉及到treeMap,arraylist的一些操作. 测试流程如下: algorithm A=new algorithm (); List testData=new ArrayList(); //循环体内的测试数据集数据量相当,切均不一样. for(int i=0;i<testData.size();i++) { long StartTime=????;//counting time A.do(te

php测试性能代码

php测试性能代码 function microtime_float () {     list ($usec, $sec) = explode(" ", microtime());     return ((float) $usec + (float) $sec); } function echotime ($name) {     static $t_start = 0;     $t_end = microtime_float();     if ($name != 'start

iOS - Quartz 2D 第三方框架 Charts 绘制图表

1.Charts 简介 使用第三方框架 Charts 绘制 iOS 图表.GitHub 源码 Charts Charts 是一款用于绘制图表的框架,可以绘制柱状图.折线图.K线图.饼状图等.Charts 只有 Swift 版本. LineChart (with legend, simple design) LineChart (with legend, simple design) LineChart (cubic lines) LineChart (gradient fill) Combine

如何在ASP.NET中用OWC绘制图表(1)

asp.net|图表 如何在ASP.NET中用OWC绘制图表 (1) 一.概述 二.设置图表引擎 三.OWC的许可证问题 四.OWC的运行机制 五.在Web服务器上安装OWC 10 六.OWC编程模式 ━━━━━━━━━━━━━ 正文: ━━━━━━━━━━━━━ 一.概述 在开发应用程序时,经常会遇到必须提供交互式图表的情况.例如,你可能在开发一个管理销售和产品数据的应用程序,数据保存在SQL Server数据库上,应用程序允许用户添加数据.更新现有数据,但除了这些功能之外,客户还要求应用程序

如何使用coreldraw vba 读取数据库,并在下面过程中调用进行编程绘制图表

问题描述 如何使用coreldraw vba 读取数据库,并在下面过程中调用进行编程绘制图表 如何使用coreldraw vba 读取数据库,并在下面过程中调用进行编程绘制图表 解决方案 http://dickeydong.cn/coreldraw-vba.html 添加对ADO的引用,之后和VB访问数据库是一样的代码