一个运行时步骤分析器-用于python。

totalrecall的Python项目详细描述


totalrecallPyPI versionBuild StatusCoverage Status

a运行时步骤探查器-用于python。

简介

聚合运行时统计信息和/或在代码中发现瓶颈是作为软件工程师最常见的挑战之一。这是一个图书馆来帮助你。与大多数现有的库相比,这一个库集中在^ {STR 1 } $步骤剖析< /强>;在由键/标签/标签和可选元数据标记的步骤中聚合运行时信息,用于创建事务形式的所有步骤的摘要。另外,它还支持装饰代码contexts和^{str1}$functions。

这是一个mvp,很可能会使用更多的分析功能进行扩展。

安装

使用pip安装

$ pip install totalrecall

使用

非常基本的example

importtotalrecallfromtimeimportsleep# ---------------------------------------------------#   EXAMPLE: runtime step profiler# ------------------------------------------------profiler=totalrecall.timer('profile something - using timer',begin=False)profiler.begin('task 1')sleep(0.1)profiler.begin('task 2')sleep(0.2)profiler.begin('task 3')sleep(0.3)profiler.end()print('[profiler.time / basic]: TIME: {0}'.format(profiler.time))print('[profiler.time / basic]: STEPS: {0}'.format(profiler.steps))# ---------------------------------------------------#   EXAMPLE: runtime step profiler (detailed)# ------------------------------------------------profiler=totalrecall.timer('profile something - using timer',begin=False,enabled=True,verbose=True,colors=True,)profiler.begin('task 1')sleep(0.1)profiler.begin('task 2')sleep(0.2)profiler.begin('task 3')sleep(0.3)profiler.end()print('[profiler.time / detailed]: TIME: {0}'.format(profiler.time))print('[profiler.time / detailed]: STEPS: {0}'.format(profiler.steps))# ---------------------------------------------------#   EXAMPLE: runtime context profiler# ------------------------------------------------profiler=totalrecall.context('profile something 2 - using context')withprofiler:sleep(1)print('[profiler.context / basic]: TIME: {0}'.format(profiler.time))print('[profiler.context / basic]: STEPS: {0}'.format(profiler.steps))# ---------------------------------------------------#   EXAMPLE: runtime function profiler# ------------------------------------------------profiler=totalrecall.function('profile something 2 - using context')@profilerdeffoo():sleep(1)print('[profiler.function / basic]: TIME: {0}'.format(profiler.time))print('[profiler.function / basic]: STEPS: {0}'.format(profiler.steps))

测试

克隆源代码:

$ make install
<>运行^ ^ {STR 1 } $多彩测试>,只使用本地环境(依赖沙箱向上):

$ make test

使用multi environment(使用tox)运行less colorgy测试

$ make test-tox

关于

这个项目主要是在缺乏现有的替代方案的情况下使用的,在我们的工作中使用^ {STR 1 } $Markable.ai在各种编程环境之间有共同的代码约定,其中{STR 1 } $ Python (研究,CV,AI)被大量使用。

学分

感谢op-bk对命名此库的创造性帮助。

许可证

在麻省理工学院的许可下发布。

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

推荐PyPI第三方库


热门话题
java Apache Flink外部Jar   创建和强制转换对象数组时发生java错误   Java,添加数组   具有相同包结构和类的java JAR   java Jenkins未能构建Maven项目   java为什么一个forloop比另一个更快,尽管它们做的“一样”?   servlets在将“/”站点迁移到Java EE包时处理contextpath引用   无法解析java MavReplugin:2.21或其某个依赖项   泛型如何编写比较器来泛化Java中的两种类型的对象?   java Android Emulator未在netbeans上加载   多线程Java使用线程对数组中的数字求和:在同步块中使用新变量作为锁:差异   java如何在JSP/servlet中设置<input>标记的值?