Palanteer 仪器库
项目描述
查看 Palanteer 并全面了解您的程序
Palanteer 是一套精益高效的工具,用于提高 Python 程序(和 C++)的软件质量。
简单的代码检测,大部分在 Python 中是自动的,提供了强大的功能:
- 收集有关时间、内存、锁等待和使用、上下文切换、数据值的有意义的原子事件。
- 记录的可视化和交互式观察:分层日志、时间线、绘图、直方图、火焰图...
- 远程命令调用和事件观察可以用 Python 编写脚本:深度测试从未如此简单
未修改的 Python 程序的执行可以直接使用类似于以下语法的语法进行分析cProfile:
- 功能进入/离开
- 解释内存分配
- 所有引发的异常
- 垃圾收集运行
- 支持多线程、协程、asyncio/gevent
收集到的事件既可以通过在线脚本自动处理,也可以使用单独的查看器进行分析(参见最后一节):
Palanteer 是一个高效、精益和全面的解决方案,可用于更好、更愉快的软件开发!
用法
可以进行分析和监控:
-
使用未修改的代码:
python -m palanteer [options] <your script>此语法与
cProfile用法类似,无需修改脚本。
默认情况下,它会尝试连接到 Palanteer 服务器。通过选项,可以选择离线分析。
启动python -m palanteer以获得帮助或参考文档。 -
使用代码检测:
有关详细信息,请参阅文档。
与仅自动功能分析相比,手动检测可以提供其他有价值的信息,例如数据、锁、...
手动工具还可能包括可远程调用的命令(命令行界面,又称 CLI),对配置和测试很有用。
这是一个工作示例:
#! /usr/bin/env python3
import sys
import random
from palanteer import *
globalMinValue, globalMaxValue = 0, 10
# Handler (=implementation) of the example CLI, which sets the range
def setBoundsCliHandler(minValue, maxValue): # 2 parameters (both integer) as declared
global globalMinValue, globalMaxValue
if minValue>maxValue: # Case where the CLI execution fails (non null status). The text answer contains some information about it
return 1, "Minimum value (%d) shall be lower than the maximum value (%d)" % (minValue, maxValue)
# Modify the state of the program
globalMinValue, globalMaxValue = minValue, maxValue
# CLI execution was successful (null status)
return 0, ""
def main(argv):
global globalMinValue, globalMaxValue
plInitAndStart("example") # Start the instrumentation
plDeclareThread("Main") # Declare the current thread as "Main", so that it can be identified more easily in the script
plRegisterCli(setBoundsCliHandler, "config:setRange", "min=int max=int", "Sets the value bounds of the random generator") # Declare the CLI
plFreezePoint() # Add a freeze point here to be able to configure the program at a controlled moment
plBegin("Generate some random values")
for i in range(100000):
value = int(globalMinValue + random.random()*(globalMaxValue+1-globalMinValue))
plData("random data", value) # Here are the "useful" values
plEnd("") # Shortcut for plEnd("Generate some random values")
plStopAndUninit() # Stop and uninitialize the instrumentation
# Bootstrap
if __name__ == "__main__":
main(sys.argv)
仪表模块的安装
直接来自 PyPI 存储的最新官方版本(来自 Linux 上的源代码,Windows 上的二进制文件)
pip install palanteer
直接来自 GitHub 源(树顶,可能不稳定)
pip install "git+https://github.com/dfeneyrou/palanteer#egg=palanteer&subdirectory=python"
来自本地检索的来源
此方法确保查看器和脚本模块与仪器库一致。
获取来源:
git clone https://github.com/dfeneyrou/palanteer
cd palanteer
mkdir build
cd build
在 Linux 上构建:
cmake .. -DCMAKE_BUILD_TYPE=Release
make -j$(nproc) install
在 Windows 上构建:(
应vcvarsall.bat事先调用或等效项,以便可以访问 MSVC 编译器)
cmake .. -DCMAKE_BUILD_TYPE=Release -G "NMake Makefiles"
nmake install
重要的!
为了有用,这个模块至少需要一个“服务器端”:
- 图形查看器
- 用于对收集的事件进行可视化分析(在线或离线)
- Python脚本模块
palanteer_scripting- 用于自动远程使用收集的事件:KPI 提取、测试、监控......
注 1:从本地源安装提供所有组件:仪器模块、脚本模块、图形查看器、测试示例和文档。
注意 2:强烈建议在服务器端和检测端之间有匹配的版本
项目详情
下载文件
下载适用于您平台的文件。如果您不确定要选择哪个,请了解有关安装包的更多信息。