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 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" 這個會再右上角生成一個圖例,用于區分什麼顔色的線條是哪一項資料
生成的圖表如下:
最新内容請見作者的github頁:http://qaseven.github.io/