以上參數最常用的是-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
文章來源于領測軟件測試網 http://www.anti-gravitydesign.com/