boom简介
boom是python替代ab的模块,并增加了部分功能。
boom安装
ubuntu 执行“pip install boom“即可,注意可能需要先执行"apt-get install libevent python-dev"。它使用Gevent创建虚拟用户,使用Requests发送请求。
boom快速入门
# boom -n1000 -c10 http://localhost
/usr/local/anaconda3/lib/python3.6/site-packages/boom/boom.py:28: MonkeyPatchWarning: Monkey-patching ssl after ssl has already been imported may lead to errors, including RecursionError on Python 3.6. Please monkey-patch earlier. See https://github.com/gevent/gevent/issues/1016
monkey.patch_all()
Server Software: nginx/1.10.3 (Ubuntu)
Running GET http://127.0.0.1:80
Host: localhost
Running 1000 queries - concurrency 10
[================================================================>.] 99% Done
-------- Results --------
Successful calls 1000
Total time 4.7209 s
Average 0.0405 s
Fastest 0.0128 s
Slowest 0.0732 s
Amplitude 0.0604 s
Standard deviation 0.009018
RPS 211
BSI Pretty good
-------- Status codes --------
Code 200 1000 times.
-------- Legend --------
RPS: Request Per Second
BSI: Boom Speed Index
Average:每批请求的平均处理时间。 Fastest:每批请求的最快处理时间。 Slowest:每批请求的最慢处理时间。 Amplitude:振幅,即最慢与最忙批次处理时间差。
boom参考
# boom -h
/usr/local/anaconda3/lib/python3.6/site-packages/boom/boom.py:28: MonkeyPatchWarning: Monkey-patching ssl after ssl has already been imported may lead to errors, including RecursionError on Python 3.6. Please monkey-patch earlier. See https://github.com/gevent/gevent/issues/1016
monkey.patch_all()
usage: boom [-h] [--version] [-m {GET,POST,DELETE,PUT,HEAD,OPTIONS}]
[--content-type CONTENT_TYPE] [-D DATA] [-c CONCURRENCY] [-a AUTH]
[--header HEADER] [--pre-hook PRE_HOOK] [--post-hook POST_HOOK]
[--json-output] [-q] [-n REQUESTS | -d DURATION]
[url]
Simple HTTP Load runner.
positional arguments:
url URL to hit
optional arguments:
-h, --help show this help message and exit
--version Displays version and exits.
-m {GET,POST,DELETE,PUT,HEAD,OPTIONS}, --method {GET,POST,DELETE,PUT,HEAD,OPTIONS}
HTTP Method
--content-type CONTENT_TYPE
Content-Type
-D DATA, --data DATA Data. Prefixed by "py:" to point a python callable.
-c CONCURRENCY, --concurrency CONCURRENCY
Concurrency
-a AUTH, --auth AUTH Basic authentication user:password
--header HEADER Custom header. name:value
--pre-hook PRE_HOOK Python module path (eg: mymodule.pre_hook) to a
callable which will be executed before doing a request
for example: pre_hook(method, url, options). It must
return a tupple of parameters given in function
definition
--post-hook POST_HOOK
Python module path (eg: mymodule.post_hook) to a
callable which will be executed after a request is
done for example: eg. post_hook(response). It must
return a given response parameter or raise an
`boom.boom.RequestException` for failed request.
--json-output Prints the results in JSON instead of the default
format
-q, --quiet Don't display progress bar
-n REQUESTS, --requests REQUESTS
Number of requests
-d DURATION, --duration DURATION
Duration in seconds
结论
ab和boom在功能上远不及multi-mechanize和nGrinder、Locust等主力python性能测试工具,甚至还比不上庞大且扩能能力差的loadrunner。只建议在对单个中间件的基准测试时使用。
可爱的python测试开发库 请在github上点赞,谢谢!
python中文库文档汇总
接口自动化性能测试线上培训大纲
python测试开发自动化测试数据分析人工智能自学每周一练
[雪峰磁针石博客]python3标准库-中文版
更多内容请关注 雪峰磁针石:简书
-
技术支持qq群: 144081101(后期会录制视频存在该群群文件) 591302926 567351477 钉钉免费群:21745728
-
道家技术-手相手诊看相中医等钉钉群21734177 qq群:391441566 184175668 338228106 看手相、面相、舌相、抽签、体质识别。服务费50元每人次起。请联系钉钉或者微信pythontesting
参考资料
网友评论