用于测量Pytest执行阶段的时间。
项目描述
pytest-execution-timer
与Pytest一起使用以测量测试执行时间的插件。
与pytest的--durations
选项明显不同,此插件测量特定的pytest启动/收集阶段。
利用pytest
钩子来测量阶段执行时间。
安装
需求
- Python 3.7或更高版本。
- Pytest 6.2或更高版本。
使用您项目的任何方法安装插件。
一些示例
pip install pytest-execution-timer
poetry add --dev pytest-execution-timer
pipenv install --dev pytest-execution-timer
或将其添加到您的requirements.txt
文件中。
用法
在运行pytest时使用--execution-timer
选项启用插件
$ pytest --execution-timer
...
Durations of pytest phases in seconds (min 100ms):
0.662 pytest_runtestloop
通过传递--minimum-duration=<value in ms>
来控制阈值(默认100ms)
$ pytest --execution-timer --minimum-duration=1000 # 1 second
理解输出
最好的方法是比较pytest_runtestloop持续时间与整个测试运行的总持续时间。示例
Durations of pytest phases in seconds (min 100ms):
0.666 pytest_runtestloop
====== 4 passed in 0.68s ======
在这个例子中,测试运行和pytest_runtestloop之间的差异不大,这意味着启动和收集阶段没有花费太多时间。
如果时间有较大的差异,请查看其他发出的阶段以了解什么花费了最多时间。
这些可以直接检查,或者使用其他工具,如性能分析器或导入计时。
许可
在MIT许可证下分发,“pytest-execution-timer”是免费的开源软件。更多信息请参阅LICENSE
文件。
项目详情
下载文件
下载适用于您平台的文件。如果您不确定选择哪个,请了解更多关于安装包的信息。
源代码分发
pytest-execution-timer-0.1.0.tar.gz (4.8 kB 查看哈希值)
构建分发
关闭
pytest-execution-timer-0.1.0.tar.gz的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 26b47da77d9e7b31ff5f22e57d636f3b3226dc7144ba524f32283bed08e94dce |
|
MD5 | 35540366708545679f7985e0766f2605 |
|
BLAKE2b-256 | 05311d652f830e552de22a38d87b758d54ffabcebd29672de29f5424c13c60a4 |
关闭
pytest_execution_timer-0.1.0-py3-none-any.whl的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | bde5fe67548eed0151ed4f9583fc2fe51bf066fd73a3a77a37a2951b33265b3c |
|
MD5 | 1f33bd997f95cedc38ba10329b8db37a |
|
BLAKE2b-256 | 92f57c9816596e1ee369e3a11e6c376991b5b3f1efe2e4984460a0bf564fe34e |