使用Python编写Mercurial(hg)扩展性能测试的方法

Sim*_*ion 5 mercurial python-2.7 mercurial-extension

我为Mercurial编写了一个扩展,例如hg dosomthing --rev 5,我想知道编写性能测试用例的正确方法是什么,以便从执行到结束时监视扩展的性能!

钽:)

Mar*_*ler 7

Mercurial支持在Python分析器下运行.只是执行

$ hg --profile dosomething --rev 5
Run Code Online (Sandbox Code Playgroud)

然后你会看到配置文件输出.有关您的一些选项,请参阅hgrc手册页.如果您只想要时序数据,那么请使用

$ hg --time dosomething --rev 5
Run Code Online (Sandbox Code Playgroud)

代替.

您还应该查看perf扩展.它多次运行命令(如timeit模块)并报告最佳运行时间.您必须扩展扩展以运行新命令,但它应该很简单,因为所有性能测试都遵循相同的模式.