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
2
votes
0 answers

Why won't line_profiler recognise my __init__.py module?

I'm trying to use the line_profiler library to profile some Python code. However, when I run the command: kernprof -l -v bots\main.py I get the following error: Traceback (most recent call last): File "C:\Python34\Scripts\kernprof-script.py",…
BitOfABeginner
  • 122
  • 1
  • 10
1
vote
2 answers

How do I use line_profiler on a wrapped function?

I've been trying to use line_profiler on a wrapped function. However, the wrapper function gets profiled instead of the wrapped function. The executable snippet below shows that I can see that my @decorate wrapper function gets profiled instead of…
Vulpo
  • 873
  • 1
  • 9
  • 25
1
vote
0 answers

Can't get cython profiling line by line to work

On the top of the .pyx file I've added: # cython: linetrace=True # distutils: define_macros=CYTHON_TRACE_NOGIL=1 CYTHON_TRACE=1 I've tried also putting macros in my setup file. Then I'm running: from mycythonmodule import func profile =…
beesleep
  • 1,322
  • 8
  • 18
1
vote
0 answers

line by line profiler in Ruby

For a quick overview of code, line profilers are very good. Python has very good line profiler. Searching gave some results but this post is very old the packages mentioned here have not been maintained. ruby-prof and Ruby's benchmark are good but I…
impopularGuy
  • 805
  • 9
  • 15
1
vote
2 answers

Git Bash: Microsoft Visual C++ 14.0 is required, but I already have it installed

I am using git to clone https://github.com/rkern/line_profiler.git on Windows 10. It is erroring out with this error but I have this installed (see image below): error: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build…
whatwhatwhat
  • 1,991
  • 4
  • 31
  • 50
1
vote
0 answers

Python line_profiler with object oriented code

I am trying to use the python line_profiler by Robert Kern for some object oriented code and I am having trouble getting the desired output. My object is of the following form: class myObj: def __init__(self,inputs): #process inputs …
algol
  • 399
  • 3
  • 15
1
vote
2 answers

cannot use line_profiler in jupyter/python2.7.5

I'm trying to use the line magic %lprun in jupyter notebook running a python 2.7.5 kernel. The code I'm trying to run is the following: %load_ext line_profiler distance = 20 veg_slope = 0 slope = 10 %lprun test = bal.run('forest', veg_slope, slope,…
1
vote
0 answers

line_profiler to trace built in functions

I know use profile or cprofile library can profile the detail CPU time for given piece of code, but it cannot specify a given function. And I know line_profiler can trace a certain function but it cannot trace deep into the third part library or…
Tiancheng Liu
  • 782
  • 2
  • 9
  • 22
1
vote
0 answers

%lprun-like module profiling using kernprof

I would like to profile certain modules using kernprof without inserting @profile decorators. Inside IPython shell %lprun has awesome feature -m module which allows to profile all lines in a specified module. But if I need to run some script from…
Pommy
  • 381
  • 2
  • 10
1
vote
1 answer

line_profiler only showing a small number of lines

Following the docs on line_profiler, I am able to profile my code just fine, but when I view the output with python -m line_profiler script_to_profile.py.lprof, I only see 27 lines of code. I expect to see about 250, because that's the length of the…
Mr. W.
  • 359
  • 3
  • 12
1
vote
0 answers

line_profiler installation failed : UnicodeDecodeError

When trying to install line_profiler via pip install line_profiler, I keep getting the same error : Installing collected packages: line-profiler Running setup.py install for line-profiler ... error Exception: Traceback (most recent call last): …
TheMrZZ
  • 188
  • 1
  • 11
1
vote
0 answers

How can I use the python line_profiler with uwsgi?

Normally I would use the @profile decorator and run the script with kernprof -l. How can I do this for code that is executed through a uwsgi server? It looks like you can add functions to be profiled through the line profiler api:…
jmilloy
  • 7,875
  • 11
  • 53
  • 86
1
vote
2 answers

line_profiler and kernprof does not work installed from pip and repro

I have tried what has been suggested. On the simplest of code, I get the familiar error that others have mentioned. The error is: @profile NameError: name 'profile' is not defined on the minimal code: @profile def hello(): …
disruptive
  • 5,687
  • 15
  • 71
  • 135
0
votes
2 answers

line_profiler: Unresolved reference 'profile' in PyCharm and IntelliJ

When using line_profiler PyCharm throws Unresolved reference 'profile'. How can I fix this?
vanya
  • 178
  • 8
0
votes
0 answers

Need help finding the best time performing lines of code to replace existing-working code

The question is very straight forward. Content here is information collected during the run of an interconnected system. I simplified functions to emphasise the bottlenecks from line_profiler into three dependend functions objectively similar to…