Methods of testing Python program performance

From , 3 Years ago, written in Python, viewed 86 times.
URL https://pastebin.vip/view/0a3b5a7a
  1. import profile
  2. profile.run('myfunction()','myfunction.profile')
  3. import pstats
  4. pstats.Stats('myfunction.profile').sort_stats('time').print_stats()
  5.  
  6. 显示结果如下:
  7. Thu Jul 03 15:20:26 2003    myfunction.profile
  8.  
  9.          1822 function calls (1792 primitive calls) in 0.737 CPU seconds
  10.  
  11.    Ordered by: internal time
  12.  
  13.    ncalls  tottime  percall  cumtime  percall filename:lineno(function)
  14.         1    0.224    0.224    0.279    0.279 myprogram.py:512(compute)
  15.        10    0.078    0.008    0.078    0.008 myprogram.py:234(first)
  16.         1    0.077    0.077    0.502    0.502 myprogram.py:249(give_first)
  17.         1    0.051    0.051    0.051    0.051 myprogram.py:1315(give_last)
  18.         3    0.043    0.014    0.205    0.068 myprogram.py:107(sort)
  19.         1    0.039    0.039    0.039    0.039 myprogram.py:55(display)
  20.       139    0.034    0.000    0.106    0.001 myprogram.py:239(save)
  21.       139    0.030    0.000    0.072    0.001 myprogram.py:314(load)
  22.       ...
  23. #//python/216

Reply to "Methods of testing Python program performance"

Here you can reply to the paste above

captcha

https://burned.cc - Burn After Reading Website