You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

custom_profile.py 794 B

123456789101112131415161718192021
  1. """
  2. 测试.py文件各个函数的运行时间
  3. """
  4. import pstats
  5. # 在cmd中使用python -m cProfile -o result.cprofile main.py
  6. # 创建 Stats 对象
  7. p = pstats.Stats('./result.cprofile')
  8. # 按照运行时间和函数名进行排序
  9. # 按照函数名排序,只打印前n行函数(其中n为print_stats(n)的输入参数)的信息,
  10. p.strip_dirs().sort_stats("cumulative", "name").print_stats(15)
  11. # 参数还可为小数, 表示前n(其中n为一个小于1的百分数, 是print_stats(n)的输入参数)的函数信息
  12. # p.strip_dirs().sort_stats("cumulative", "name").print_stats(0.5)
  13. # 查看调用main()的函数
  14. # p.print_callers(0.5, "main")
  15. # 查看main()函数中调用的函数
  16. # p.print_callees("main")
  17. # pip安装snakeviz后,在cmd里运行如下命令:
  18. # snakeviz result.out

基于pytorch lightning的机器学习模板, 用于对机器学习算法进行训练, 验证, 测试等, 目前实现了神经网路, 深度学习, k折交叉, 自动保存训练信息等.

Contributors (1)