Erlang13A出来后,有人就做了
新旧版本的性能测试。作者自己写了小小的Web服务器进行测试,测试工具是apaceh的
ab,这是个命令行工具
参考
ab工具可以将测试结果输出到方便gnuplot处理的文本文件中。
方法是使用-g参数其结果可以输出到指定文件
$ab -g result.txt -n 1000 -c 100 http://www.hao123.com/
$ head result.txt
starttime seconds ctime dtime ttime wait
Thu Mar 19 00:58:35 2009 1237395515 3 5 8 4
Thu Mar 19 00:58:34 2009 1237395514 3 5 8 4
Thu Mar 19 00:58:29 2009 1237395509 3 5 8 4
Thu Mar 19 00:58:34 2009 1237395514 3 5 8 4
Thu Mar 19 00:58:34 2009 1237395514 3 5 8 4
Thu Mar 19 00:58:29 2009 1237395509 3 5 8 4
Thu Mar 19 00:58:34 2009 1237395514 3 5 8 4
Thu Mar 19 00:58:35 2009 1237395515 3 5 8 4
Thu Mar 19 00:58:34 2009 1237395514 3 5 8 4
每一行代表一个请求,被空格划分成10个column,我们关心的是第7、8、9、10行的数据,分别代表:
ctime:connection time
dtime: processing time
ttime: total time, = connection time + processing time
wait:wait time
$ gnuplot
set terminal png
set output "http_benchmark.png"
set xlabel "request"
set ylabel "ms"
plot "http_benchmark.txt" using 7 with lines title "ctime", \
"http_benchmark.txt" using 8 with lines title "dtime", \
"http_benchmark.txt" using 9 with lines title "ttime", \
"http_benchmark.txt" using 10 with lines title "wait"
Lies, Damned Lies, and Benchmarks中的数据不是直接来自-g参数生成的文件,每次ab执行完后会打印此次测试的概要:
Server Software:
Server Hostname: 127.0.0.1
Server Port: 8889
Document Path: /
Document Length: 1 bytes
Concurrency Level: 10
Time taken for tests: 14.004 seconds
Complete requests: 10000
Failed requests: 0
Write errors: 0
Total transferred: 390000 bytes
HTML transferred: 10000 bytes
Requests per second: 714.09 [#/sec] (mean)[color=red][/color]
Time per request: 14.004 [ms] (mean)
Time per request: 1.400 [ms] (mean, across all concurrent requests)
Transfer rate: 27.20 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 11 347.8 0 11005
Processing: 0 3 11.5 2 443
Waiting: 0 2 11.5 2 443
Total: 0 14 348.0 2 11012
Percentage of the requests served within a certain time (ms)
50% 2
66% 3
75% 3
80% 3
90% 4
95% 7
98% 12
99% 13
100% 11012 (longest request)
每次在不同并发请求下测试每秒能处理的请求数,在不同并发请求情况下多次测试取平均值。
在一张图中表现两条完全不同尺度的曲线的例子:
例如,曲线1的y值范围在1~2间,曲线2的y值范围在0~3000之间
数据例子如下
1701 1076.20 1.277
1751 1111.68 1.280
1801 1145.26 1.283
1851 1170.67 1.279
1901 1213.69 1.292
1951 1236.83 1.282
2001 1273.59 1.284
2051 1309.72 1.283
gnuplot命令如下:
set y2tics 0, 250
set ytics nomirror
plot 'data.txt' using 1:3 with lines,\
'data.txt' using 1:2 axes x1y2 with lines
更多更详细的例子
参考文档:
http://iceskysl.1sters.com/?action=show&id=386
http://www.ibm.com/developerworks/cn/linux/l-gnuplot/index.html
http://www.lotto-kim.net/eng/blog/using_gnuplot_to_show_results_from_ab