Apache 自带的性能测试工具 ab 的简单使用:
打开命令提示符窗口。进入Apache路径下的bin目录:
C:Documents and SettingsAdministrator>cd
C:>cd "C:Program FilesApache GroupApache2bin"
比如我们要测试“同时处理50个请求并运行 1000 次 phpinfo.php 文件”,可以输入 ab -c 50 -n 1000
http://localhost/phpinfo.php
我运行了一下,我的机器受不了了,慢的要死
现在测试结束,又快了
我的配置是很老的~~~PIII 667 256M VIA 20G IDE接口
结果:
E:Apache2bin>ab -c 10 -n 1000
http://localhost/a.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 localhost (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/2.0.52
Server Hostname: localhost
Server Port: 80
Document Path: /a.php
Document Length: 34970 bytes
Concurrency Level: 10
Time taken for tests: 233.115203 seconds
Complete requests: 1000
Failed requests: 0
Write errors: 0
Total transferred: 35144668 bytes
HTML transferred: 34970000 bytes
Requests per second: 4.29 [#/sec] (mean)
Time per request: 2331.152 [ms] (mean)
Time per request: 233.115 [ms] (mean, across all concurrent requests)
Transfer rate: 147.22 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 50 91.4 10 1732
Processing: 901 2271 946.4 2042 8021
Waiting: 901 2116 881.3 1902 7871
Total: 971 2321 972.2 2062 8231
Percentage of the requests served within a certain time (ms)
50% 2062
66% 2453
75% 2693
80% 2904
90% 3444
95% 4155
98% 5337
99% 6299
100% 8231 (longest request)