Questions tagged [cprofile]

cProfile is a built-in Python module that describes the run time performance of a program, providing a variety of statistics.

cProfile is a built-in module suitable for profiling Python programs. It's designed as a faster drop-in replacement for the profile implementation. cProfile is implemented as C-Extension which provides less overhead than the pure Python implementation of profile, but it may not be available in all Python implementations.

It can be used in a Python file:

import cProfile
cProfile.run('insert_your_code_to_profile_here')

But also from the command-line, to profile a script:

python -m cProfile [-o output_file] [-s sort_order] (-m module | myscript.py)

Sources:

230 questions
0
votes
1 answer

IndexError: list index out of range when trying to run cProflie

I have a main.py script in my project that runs a model which is organized into a python package. The project structure looks like this: project/ model/ data/ ... __init__.py ... tests/ ... …
pbreach
  • 16,049
  • 27
  • 82
  • 120
0
votes
1 answer

Why do I get a TypeError when I call cProfile.run()?

import math import random import cProfile import pstats from goody import irange def partition(alist, left, right): def swap(i,j): alist[i],alist[j] = alist[j],alist[i] pivot = alist[right] …
0
votes
1 answer

I think my program is bottlenecked by file I/O, and I need a better solution

My program interacts with an API, performs calculations, and builds a Gui using information, some of which is stored in local files (to preserve information between logins). When using cProfile to profile my code, I get the following…
Tyler Cheek
  • 327
  • 2
  • 14
0
votes
1 answer

Using cProfile or line_profile on a Python script in /cgi-bin/?

Is there a way to run cProfile or line_profile on a script on a server? ie: how could I get the results for one of the two methods on http://www.Example.com/cgi-bin/myScript.py Thanks!
Parker
  • 8,539
  • 10
  • 69
  • 98
0
votes
1 answer

Is deque from the collections module really 100 times faster at prepending than list in Python?

Is there something wrong with my code? I'm getting a 100 times speed up when timing a simple function using deque from the collections module as opposed to a regular list. >>> from collections import deque as dl >>> import cProfile >>> >>> def…
X-Mann
  • 327
  • 2
  • 5
  • 15
0
votes
1 answer

can profilehooks, write .prof files?

I would like to write the profilehooks output to a .prof file. In order to convert the file to a qcachgrind file and visualize the profiling results. (I can't use cProfile as cProfile, does not profile the code)
Davoud Taghawi-Nejad
  • 16,142
  • 12
  • 62
  • 82
0
votes
2 answers

invalid syntax when run cProfile

I tries to run python -m cProfile simple_test_script.py. I'm on Windows 7, Python 2.7.10. simple_test_script.py: import numpy as np from numpy.linalg import eigvals def run_experiment(niter=100): K = 100 results = [] for _ in…
Isak La Fleur
  • 4,428
  • 7
  • 34
  • 50
0
votes
1 answer

Understanding python cProfile output

My python scripts parses files sequentially, and makes simple data cleaning and writes to a new csv file. I'm using csv. the script is taking awfully long time to run. cProfile output is as follows: I have done a lot of googling before posting the…
Krishna Deepak
  • 1,735
  • 2
  • 20
  • 31
0
votes
1 answer

How can i create kgring file using python?

I'm new in python programming. I try to learn cProfiler and using pyprof2calltree . I'm using python 2.7 , windows 7 .I installed pyprof2calltree 1.3.2 and qcachegrind074-x86.The problem is that i coudldn't find any tutorial about using…
BBG_GIS
  • 306
  • 5
  • 17
0
votes
1 answer

Why is my code so slow?

I'm new to cProfile. I ran cProfile on my program and it spit out this: ncalls tottime percall cumtime percall filename:lineno(function) 1 290.732 290.732 313.069 313.069 newad.py:1() The first line of newad.py is: 1 …
James.Wyst
  • 859
  • 3
  • 8
  • 13
0
votes
2 answers

What does "{built-in method mainloop}" mean in cProfile?

Sorted by total time, the second longest executing function is "{built-in method mainloop}" ? I looked at the same entry with pstats_viewer.py and clicked it and it says : Function Exclusive time Inclusive time Primitive calls Total calls…
0
votes
1 answer

cProfile - keep data in Python object/defer write to disk

I have a function that I want to analyse with cProfile, but I also save a lot of other analysis about the result - this currently gets saved into a directory whose name is generated programatically, and I would like the profile data to be saved in…
lvc
  • 34,233
  • 10
  • 73
  • 98
0
votes
2 answers

Python: Interpreting cProfile logs

I have a method to determine the most compatible person for every other person. Basically there are two nested loops over the items of a dict that maps from a person to a list (where similar lists determine compatibility), there compat is computed…
Zakum
  • 2,157
  • 2
  • 22
  • 30
0
votes
0 answers

How to profile (visually) a CUDA code which is implemented in a python package through C extension?

Possible Duplicate: How to profile PyCuda code with the Visual Profiler? The CUDA visual profiler (nvvp) requires an executable entry for profiling, but my CUDA code is implemented in a python package by through C extension. Is there anyway to do…
Hailiang Zhang
  • 17,604
  • 23
  • 71
  • 117
0
votes
1 answer

How to do cProfile in django production server

I want to monitor my views in Django aplication at production environment.So, I came across the solution script I tested in my local environment.works fine!!. When I went live with the production environment, I was facing issue with Unhandled…
Nava
  • 6,276
  • 6
  • 44
  • 68
1 2 3
15
16