如何使用GNUPlot从ApacheBench输出文件中绘制响应时间的直方图?

Gre*_*g B 2 gnuplot histogram apachebench

我正在针对我正在构建的网站运行一些基准测试,并希望生成响应时间的图表.这是我的ApacheBench用法:

> ab -n 100 -c 10 -g foo.tsv http://foo/
Run Code Online (Sandbox Code Playgroud)

这给了我一个TSV文件,其数据如下:

starttime                   seconds         ctime    dtime  ttime   wait
Tue Dec 03 16:24:53 2013    1386087893      2        413    415     367
Tue Dec 03 16:24:49 2013    1386087889      1        468    469     452
Tue Dec 03 16:24:54 2013    1386087894      9        479    488     446
Tue Dec 03 16:24:49 2013    1386087889      1        497    498     437
Tue Dec 03 16:24:54 2013    1386087894      33       465    498     458
Tue Dec 03 16:24:53 2013    1386087893      1        507    508     506
Tue Dec 03 16:24:51 2013    1386087891      0        544    544     512
Run Code Online (Sandbox Code Playgroud)

我想将此数据转换为Y轴上的数量和X轴上的响应时间(ttime)的直方图.

我的剧情脚本在下面,但我得到的是一个空的(零字节)jpeg文件.

clear
reset
set output "out.jpg"
# Select histogram data
set style data histogram

set style fill solid border

plot 'foo.tsv' using 5
exit
Run Code Online (Sandbox Code Playgroud)

如何生成此直方图?


奖金问题.我意识到这些数据可能会导致许多数据点出现一次或两次点击,那么如何将ttime舍入到最接近的10ms,以便为每个点击次数减少更少的数据点?

Arp*_*uch 5

将其复制到.p文件中.

touch foo.p   
gedit foo.p  
Run Code Online (Sandbox Code Playgroud)

现在将此数据粘贴到该文件中并保存,

 # output as png image
 set terminal png

 # save file to "benchmark.png"
 set output "benchmark.png"

 # graph a title
 set title "ab -n 100 -c 10 -g foo.tsv http://foo/"

 # nicer aspect ratio for image size
 set size 1,0.7

 # y-axis grid
 set grid y

 # x-axis label
 set xlabel "request"

 # y-axis label
 set ylabel "response time (ms)"

 # plot data from "foo.tsv" using column 9 with smooth sbezier lines
 plot "foo.tsv" using 9 smooth sbezier with lines title "server1:"
Run Code Online (Sandbox Code Playgroud)

现在生成foo.p的绘图文件::

    gnuplot foo.p
Run Code Online (Sandbox Code Playgroud)