bjghzly 发表于 2017-4-23 11:03:33

python性能测试

python -m profilexxxxx.py> log.txt

打开log.txt查看,搜索你所关心的方法调用耗费的时间。
profile的统计结果分为ncalls, tottime, percall, cumtime, percall, filename:lineno(function)。
ncalls函数的被调用次数
tottime函数总计运行时间,除去函数中调用的函数运行时间
percall函数运行一次的平均时间,等于tottime/ncalls
cumtime函数总计运行时间,含调用的函数运行时间
percall函数运行一次的平均时间,等于cumtime/ncalls
filename:lineno(function)函数所在的文件名,函数的行号,函数名



更多信息请见http://blog.csdn.net/lanphaday/archive/2007/01/15/1483728.aspx

注:profile可能使用profile模块,有个hotspot好像更好些,都有api可以调用
页: [1]
查看完整版本: python性能测试