1]介紹
webbench最多可以模擬3萬個併發連接去測試網站的負載能力,個人感覺要比Apache自帶的ab壓力測試工具好,安裝使用也特別方便。
適用系統:Linux
[2]下載
[root@localhost src]# wget http://blog.s135.com/soft/linux/webbench/webbench-1.5.tar.gz ←下載源程序
–15:46:22– http://blog.s135.com/soft/linux/webbench/webbench-1.5.tar.gz
=> `webbench-1.5.tar.gz’
Resolving blog.s135.com… 122.200.66.145
Connecting to blog.s135.com|122.200.66.145|:80… connected.
HTTP request sent, awaiting response… 200 OK
Length: 7,675 (7.5K) [application/octet-stream]
100%[====================================>] 7,675 8.62K/s
15:46:30 (8.62 KB/s) - `webbench-1.5.tar.gz’ saved [7675/7675]
[3]解壓、編譯和安裝
[root@localhost src]# tar zxvf webbench-1.5.tar.gz ←解壓源文件
webbench-1.5/
webbench-1.5/webbench.1
webbench-1.5/socket.c
webbench-1.5/webbench.c
webbench-1.5/Makefile
webbench-1.5/debian/
webbench-1.5/debian/rules
webbench-1.5/debian/dirs
webbench-1.5/debian/copyright
webbench-1.5/debian/control
webbench-1.5/debian/changelog
webbench-1.5/COPYRIGHT
webbench-1.5/ChangeLog
[root@localhost src]# cd webbench-1.5
[root@localhost webbench-1.5]# make ←編譯程序
cc -Wall -ggdb -W -O -c -o webbench.o webbench.c
webbench.c:77: warning: unused parameter ’signal’
cc -Wall -ggdb -W -O -o webbench webbench.o
ctags *.c
[root@localhost webbench-1.5]# mkdir /usr/local/man ←建立相應目錄(否則導致無法正常安裝)
[root@localhost webbench-1.5]# make install ←安裝程序
install -s webbench /usr/local/bin
install -m 644 webbench.1 /usr/local/man/man1
install -d /usr/local/share/doc/webbench
install -m 644 debian/copyright /usr/local/share/doc/webbench
install -m 644 debian/changelog /usr/local/share/doc/webbench
[4]運行和顯示運行結果
[root@localhost html]# webbench -c 100 -t 30 http://192.168.1.235/index.html ←參數說明:
-c表示併發數,-t表示時間(秒)
Webbench - Simple Web Benchmark 1.5
Copyright (c) Radim Kolar 1997-2004, GPL Open Source Software.
Benchmarking: GET http://192.168.1.235/index.html
100 clients, running 30 sec.
Speed=16084 pages/min, 152872 bytes/sec. ←運行結果顯示
Requests: 8042 susceed, 0 failed.
================================
如果遇到以下錯誤:
[root@localhost webbench-1.5]# make && make install
cc -Wall -ggdb -W -O -c -o webbench.o webbench.c
make: cc: Command not found
make: *** [webbench.o] Error 127
表示需要安裝 gcc aptitude install gcc