2024-04-24 04:31:42 发布
网友
我在Python中寻找一个测试脚本来测试一些东西,看看它在各种系统上完成的速度/速度。在
只是一些简单的命令被循环,使脚本需要10秒才能完成,并报告它使用了多少cpu,多少内存和完成需要多长时间?在
我想对于内存部分,我们将使用memory_profiler,我猜psutil在开始时调用5个读数(全部以2秒分隔),然后是平均cpu使用量,1个在脚本的中间,5个在结尾(都以2秒分隔)
memory_profiler
psutil
我该怎么做呢?或者已经有一个可用的脚本了,我找不到任何足够好的东西。在
IPython有%timeit:
%timeit
%timeit foo()
line_profiler和memory_profiler可以从IPython控制台运行:
更多详细信息:http://www.huyng.com/posts/python-performance-analysis/
平均CPU是。。。更棘手。Linux确实报告了一种随时间推移的平均CPU使用率,请检查此项:https://unix.stackexchange.com/questions/145247/understanding-cpu-while-running-top-command
IPython有
%timeit
:line_profiler和memory_profiler可以从IPython控制台运行:
^{pr2}$更多详细信息:http://www.huyng.com/posts/python-performance-analysis/
平均CPU是。。。更棘手。Linux确实报告了一种随时间推移的平均CPU使用率,请检查此项:https://unix.stackexchange.com/questions/145247/understanding-cpu-while-running-top-command
相关问题 更多 >
编程相关推荐