• Like
  • Save
Profiling in python
Upcoming SlideShare
Loading in...5
×
 

Profiling in python

on

  • 311 views

 

Statistics

Views

Total Views
311
Views on SlideShare
311
Embed Views
0

Actions

Likes
0
Downloads
0
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Profiling in python Profiling in python Presentation Transcript

    • PROFILING IN PYTHON John Saturday, December 21, 2013
    • introduction to the profiler • A profiler is a program descibes the run time performance of a program. • Python standard library provide 3 difference profiler: – cProfile : is recommende for most users. – profile: a pure python module whose interface imitated by cProfile – hotshot: an experimental C module that focused on minimizing the overhead of profiling
    • Quick example Profile an application 1. use command line: $ python -m cProfile myscript.py 2. or add into code with main function: impor cProfile cProfile.run(‘main()’) The result looks like:
    • Cython profiling basic Enable it for source file • profiling can be enabled by adding at the top of file #cython: profile=True • Use a special decorator disable profiling for one function only: cimport cython @cython.profile(False) def my_func(): pass Use pstats module review the profile import pstats p = pstats.Stats(‘fooprof’) p.strip_dirs().sort_stats(‘time’) .print_stats()
    • Reference • http://docs.python.org/2/library/profile.html
    • Reference • http://docs.python.org/2/library/profile.html