分析

使用cprofile执行配置文件测试。

此插件实现 startTestRun() 并取代 event.executeTests 具有 cProfile.Profile.runcall() . 它实现了 beforeSummaryReport() 在最终测试摘要时间之前输出分析信息。配置文件选项 filenamesortrestrict 可用于更改保存分析信息的位置和显示方式。

通过使用 --plugin=nose2.plugins.prof 选项并用激活它 --profile 或者放入相应的条目 (pluginalways_on )在配置文件的各个部分中。

启用此插件

此插件是内置的,但默认情况下不加载。

即使您指定 always-on = True 在配置中,除非您也启用它,否则它不会运行。您可以通过将以下内容放入 unittest.cfgnose2.cfg 文件

[unittest]
plugins = nose2.plugins.prof

这个 plugins 参数可以包含插件名称列表,包括 nose2.plugins.prof

配置 [事件探查器]

always-on
违约:

类型:

布尔

filename
违约:

类型:

STR

restrict
违约:

[]

类型:

列表

sort
违约:

累积的

类型:

STR

示例配置

默认配置相当于在 unittest.cfg 文件。

[profiler]
always-on = False
filename = 
restrict = 
sort = cumulative

命令行选项

-P DEFAULT, --profile DEFAULT

在探查器下运行测试

插件类引用:探查器

class nose2.plugins.prof.Profiler(*args, **kwargs)[源代码]

分析测试运行

beforeSummaryReport(event)[源代码]

输出分析结果

startTestRun(event)[源代码]

设置探查器