Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Python Code
profiling
JACKSON ISAAC
S7 B.TECH CSE
AMRITA VISHWA VIDYAPEETHAM, INDIA
What Is Profiling?
 Analysis of a program to measure the memory used by a certain module,
frequency and duration of funct...
Development tools in python
 Line_profiler
 Memory_profiler
 Clone digger
History of line_Profiler
 Initial Release v1.0b1 (2008) by Robert Kern.
 v1.0b2 (2009) – Fixes related to timing overflo...
Installing line_profiler
 Using pip – “pip install line_profiler”
 From source:
 git clone https://github.com/rkern/lin...
Using Line_PRofiler
 Adding profiler to the code:
@profile
def foo(bar):
…
 Running line_profiler:
 kernprof.py -l exam...
Live DEMO !
Understanding output
 Function : Displays the name of the function which is profiled and its line number.
 Line# : Line ...
advantages
 Line_profiler helps us to point out which module of our code is running
slower than expected by profiling the...
Contact
 Website: isaacjackson.me
 Blog: www.jacksonisaac.wordpress.com
 Email: jacksonisaac2008@gmail.com
 Twitter/iJ...
Thank You
Upcoming SlideShare
Loading in …5
×
Upcoming SlideShare
Python - code quality and production monitoring
Next
Download to read offline and view in fullscreen.

1

Share

Download to read offline

Python code profiling - Jackson Isaac

Download to read offline

FUDCon 2015, Pune Presentation on Python Code Profiling.

Related Books

Free with a 30 day trial from Scribd

See all

Python code profiling - Jackson Isaac

  1. 1. Python Code profiling JACKSON ISAAC S7 B.TECH CSE AMRITA VISHWA VIDYAPEETHAM, INDIA
  2. 2. What Is Profiling?  Analysis of a program to measure the memory used by a certain module, frequency and duration of function calls and the time complexity of the same.  Such profiling tools are termed as ‘profilers’.
  3. 3. Development tools in python  Line_profiler  Memory_profiler  Clone digger
  4. 4. History of line_Profiler  Initial Release v1.0b1 (2008) by Robert Kern.  v1.0b2 (2009) – Fixes related to timing overflow on Windows.  v1.0b3 (2011) – Update Compatibility for newer versions of Cython and IPython.  v1.0 (2014, stable release) – Added compatibility for Python 3.x  Previously supported by kmike’s bitbucket fork of line_profiler.
  5. 5. Installing line_profiler  Using pip – “pip install line_profiler”  From source:  git clone https://github.com/rkern/line_profiler.git  cd line_profiler  sudo python setup.py install (for python 2.7.x)  sudo python3 setup.py install (for python3)
  6. 6. Using Line_PRofiler  Adding profiler to the code: @profile def foo(bar): …  Running line_profiler:  kernprof.py -l example.py  python -m line_profiler example.py.lprof  python3 -m line_profiler example.py.lprof
  7. 7. Live DEMO !
  8. 8. Understanding output  Function : Displays the name of the function which is profiled and its line number.  Line# : Line number of the code in the respective file.  Hits : Number of times the code in the respective line was executed.  Time : Total amount of time spent in executing the line in ‘Timer unit’ (i.e 1e-06s here). May vary from system to system.  Per Hit : The average amount of time spent in executing the line once in Timer Unit.  % Time : The percentage of time spent on that line with respect to the total amount of recorded time spent in the function.  Line Contents : It displays the actual source code.
  9. 9. advantages  Line_profiler helps us to point out which module of our code is running slower than expected by profiling the time taken by each line of code.  Helps in testing large projects, time spent by modules to execute a particular function.  Using this data we can modify and improve our code to build faster and better programs and softwares.
  10. 10. Contact  Website: isaacjackson.me  Blog: www.jacksonisaac.wordpress.com  Email: jacksonisaac2008@gmail.com  Twitter/iJacksonIsaac  LinkedIn/JacksonIsaac  github.com/jacksonisaac  Mozillian/ www.mozillians.org/en-US/u/jacksonisaac2008/
  11. 11. Thank You
  • alidev85

    Nov. 1, 2016

FUDCon 2015, Pune Presentation on Python Code Profiling.

Views

Total views

2,126

On Slideshare

0

From embeds

0

Number of embeds

877

Actions

Downloads

4

Shares

0

Comments

0

Likes

1

×