Questions tagged [line-profiler]

Use this tag for questions about the Python "line_profiler" package. If you have a question about performance, or how to optimize your code based on "line_profiler" results, please use the more generic "performance" or "optimization" tags instead.

line_profiler is an external package allowing to measure the execution time (both relative and absolute) spent in each line. This can be an important utility to find bottlenecks or hotspots in python functions.

66 questions
43
votes
6 answers

How do I use line_profiler (from Robert Kern)?

I have tried using the line_profiler module for getting a line-by-line profile over a Python file. This is what I've done so far: 1) Installed line_profiler from pypi by using the .exe file (I am on WinXP and Win7). Just clicked through the…
Alex Tereshenkov
  • 3,340
  • 8
  • 36
  • 61
24
votes
2 answers

Python line_profiler code example

I am trying to figure out how I can run Python's line_profiler to get the line by line execution times in the format given in the answer to this question. I installed the module and am calling its LineProfiler object as below but the output I get is…
Zhubarb
  • 11,432
  • 18
  • 75
  • 114
13
votes
2 answers

Using line profiler with multiprocessing

How can you profile a python module that use multiprocessing (multiprocessing.Pool.map) so each spawned process will be also profiled line by line. Currently I use line_profiler for profiling but it doesn't support multiprocessing. Is there a way to…
Drxxd
  • 1,860
  • 14
  • 34
12
votes
1 answer

Using line_profiler with numba jitted functions

Is it possible to use line_profiler with Numba? Calling %lprun on a function decorated with @numba.jit returns an empty profile: Timer unit: 1e-06 s Total time: 0 s File: Function: conv at line 1 Line # Hits …
sudo
  • 503
  • 4
  • 12
12
votes
5 answers

Change Time Unit with Kernprof

I've started looking for bottlenecks in Python using line_profiler. Right now, I am doing that by running kernprof -l -v myFile.py However, the unit of time seems to be at 1e-6, which lead to output results such as 132329040. How can I increase the…
FooBar
  • 15,724
  • 19
  • 82
  • 171
11
votes
1 answer

Cannot use line_profiler with Cython

Based on the answer to this question I was trying to use the line_profiler with a cythonized function. On the abovementioned question, the accepted answer gives us an example on how to use it with jupyter notebook. However, when I try to build the…
Pedro Braz
  • 2,261
  • 3
  • 25
  • 48
7
votes
3 answers

Use LineProfiler for line-by-line profiling of Django App

I want to use line profiler to profile my django project to show the analysis of code performance. I am following these links:…
Sneha Shinde
  • 343
  • 7
  • 18
6
votes
1 answer

How do we profile memory, CPU load for flask API's on runtime?

I'm using python 3 for my flask app which is running in a port 5000. It has one sample API. I need to profile memory, CPU usage while hitting this API from REST or Browser. Please help me out for better solution. import logging from flask import…
6
votes
1 answer

Boto3 put_object() is very slow

TL;DR: Trying to put .json files into S3 bucket using Boto3, process is very slow. Looking for ways to speed it up. This is my first question on SO, so I apologize if I leave out any important details. Essentially I am trying to pull data from…
fowtom
  • 83
  • 1
  • 5
5
votes
0 answers

line_profiler cannot find the current file when using jupyter notebook

I use line_profiler in my .ipynb file with vscode: from line_profiler import LineProfiler lpf =…
5
votes
1 answer

No module named 'line_profiler'

I am trying to do line profile and memory profile in python. I imported line_profiler by from line_profiler import LineProfiler when I run my code, I get the error message: ModuleNotFoundError: No module named 'line_profiler' when I try to install…
Shah
  • 51
  • 1
  • 2
5
votes
0 answers

line profiling Cython 0.25

I am trying to line profile some code I wrote in Cython. But I cannot get it to work. I have tried to follow all the steps given in How to profile cython functions line-by-line But I dont get any timings out as a result. What I done is posted…
Erik Kjellgren
  • 215
  • 3
  • 8
5
votes
1 answer

Python line_profiler not finding module

I recognize that this is an installation failure on my part, and I'm sorry to lay this uninteresting and inconsequential question at your feet, but for the life of me I can't manage to figure out what is going wrong and I've run out of ideas. I'm…
4
votes
1 answer

Python line_profiler with multithread

I would like to profile a code using line_profiler, where there are threads. With a native/naive code implementation, the following code will not capture the time spent by the thread in do_other-stuff from line_profiler import LineProfiler import…
cpeusteuche
  • 339
  • 1
  • 3
  • 11
4
votes
1 answer

Line profiling with cython in jupyter notebook

I'm trying to use liner_profiler library in jupyter notebook with cython function. It is working only halfway. The result I get only consist of first row of the function and no profiling results. %%cython -a # cython: linetrace=True # cython:…
Alex T
  • 3,529
  • 12
  • 56
  • 105
1
2 3 4 5