以上参数最常用的是-n 在测试会话中所执行的请求个数;和-c 一次同时产生的并发请求个数。
2.3 实例
假设我们要测试一个PHP论坛系统,其中一个性能测试用例是:“同时处理50个并发请求并运行 1000 次index.php 首页”,我们可以在cmd shell中输入 ab -n 1000 -c 50 http://172.16.11.180:88/bbs/index.php,运行结束后,ab会自动显示测试结果,如下:
E:\Webser\Apache2\bin>ab -n 1000 -c 50 http://172.16.11.180:88/bbs/index.php
This is ApacheBench, Version 2.0.41-dev <$Revision: 1.121.2.12 $> apache-2.0
Copyright (c) 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Copyright (c) 1998-2002 The Apache Software Foundation, http://www.apache.org/
Benchmarking 172.16.11.180 (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Completed 600 requests
Completed 700 requests
Completed 800 requests
Completed 900 requests
Finished 1000 requests
Server Software: Apache
Server Hostname: 172.16.11.180
Server Port: 88