附加费是一个基准测试Web服务器的工具

surcharge的Python项目详细描述


DownloadsLatest Version

问题

  • ProgressBar问题
  • DNS解析错误

简介

附加费是一个用于对web服务器进行基准测试的工具,如apache benchmark。 附加费使用gevent网络库。使用greenlets允许在内存不足的情况下生成许多并发请求。 使用requests库发出http请求。

要求

此代码已在Python2.7上运行

# install by the setup
greenlet==0.4.0
gevent==0.13.6
requests==1.2.3
progressbar==2.3

安装

$ pip install surcharge #and enjoy

测试

命令示例

# simple call
$ surcharge http://google.com --numbers 10 --concurrency 5

# standard stdout
Server: gws

URL: http://173.194.67.138:80

Concurrency level: 5

Options: {'cookies': {}, 'timeout': 2.0}


100% |############################|


Number process requests: 10
Time taken for tests: 0.57
Complete requests: 10
Failed requests: 0
Faster request: 0.045
Slower request: 0.059
Time per request (only success): 0.051
Request per second: 98.57

# call with multiple cookies
$ surcharge http://httpbin.org/cookies --cookies "{'ck':1, 'cook':value}"

# call with HTTP Basic Auth
$ surcharge https://secure.test.com --auth "user:password"

# bench during 10 seconds
$ surcharge http://google.com --concurrency 10 --duration 10

示例api

 # see the constructor or the surcharge/cli.py for more details
 >>> from surcharge.core import Surcharger
 >>> surcharge = Surcharger(url='http://google.com')
 >>> surcharge()

 >>> surcharge.result
 defaultdict(<type 'list'>, {200: [0.06690406799316406]})

 # compute simple stat
 >>> from surcharge.core import SurchargerStats
 >>> surcharge_stats = SurchargerStats(surcharge)
 >>> surcharge_stats()

 >>> surcharge_stats.stats
 {'RPS': 14.20353538774128,
'exec_time': 0.07088184356689453,
'max': 0.0704050064086914,
'min': 0.0704050064086914,
'moy': 0.0704050064086914,
'requests_process': 0.0704050064086914,
'total': 1,
'total_failed': 0,
'total_success': 1}

 # By default, stdout is used to display the stats
 # You can override the SurchargerStats.send method and make what you want with the stats

 # example with a *request" option (auth)
 >>> surcharge = Surcharger(url='http://google.com', **{'auth': ('user', 'pass')})

用法

Usage:
    surcharge <url>
        [--method=<method>]
        [--concurrency=<clients>]
        [--numbers=<requests> | --duration=<seconds>]
        [--timeout=<seconds>]
        [--cookies=<cookies>]

Options:
    -h --help                           Show this screen.
    -v --version                        Show version.
    -m --method=<method>                HTTP method [default: GET].
    -c --concurrency=<clients>          Number of multiple requests to perform at a time [default: 1].
    -n --numbers=<requests>             Number of requests to perform for the benchmarking session [default: 1].
    -D --duration=<seconds>             Duration in seconds. Override the --numbers option [default: 0]
    -T --timeout=<seconds>              You can tell requests to stop waiting for a response after a given number of seconds [default: 2].
    -C --cookies=<cookies>              Send your own cookies. [default: {}]

日志

您可以在/tmp/associty_activity.log日志文件中检索一些信息。

已弃用-需要重构

(since 0.8) Overflow is a module of Surcharge. It’s allows to launch several benchmarks dynamically through the network. Overflow uses the zeroMQ library.

许可证

这个项目是在麻省理工学院的许可证下完成的,许可证文件中有一个副本。

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java从JTextArea获取文本,并将其调用到ActionPerformed方法   servlet中创建java json对象时出错   java将ActionListeners添加到按钮数组中   java防止圆联合上的死锁   java Google Play Services“登录失败。请检查您的网络连接并重试”   java spring mvc,css不起作用   java在jfreechart上显示标签   使用TestNG的selenium automation中出现java“未找到任何测试。未运行任何内容”错误   BufferedReaderJava。伊奥。IOException:流已关闭   java希望为所有表形成一个通用的更新查询   java仅当元音不以单词开头时才删除元音   java一个Spring项目中有多少配置文件?   java当数组中有参数时,如何发送post请求?   java如何使用Zuul中的CORS作为API网关+AngularJS+微服务   Java是否有不需要添加显式jar引用的内部JSON库?   java JavaFX CheckBoxTreeItem选择   java自定义布尔反序列化器在Gson中不工作