網上有很多介紹apache的ab的,卻很難找到-p選項具體怎麼用,簡單實踐並總結一下:
-p選項指定post文件的位置;-T選項指定post文件的編碼方式,默認是明文,如果指定-T 'application/x-www-form-urlencoded',則表示post文件使用urlencode
一個小例子
命令:
cd /usr/local/apache2/bin
sudo ./ab -c 10 -n 100 -p /home/post -T 'application/x-www-form-urlencoded' http://www.abc.cn/test
/home/post文件內容:
requestData=a%3A1%3A%7Bs%3A7%3A%22topicID%22%3Bs%3A12%3A%22101305598452%22%3B%7D
(根據echo 'requestData=' . urlencode(serialize(array('topicID' => '101305598452')));得到)