cprofile

Using cProfile results with KCacheGrind

I'm using cProfile to profile my Python program. Based upon this talk I was under the impression that KCacheGrind could parse and display the output from cProfile. However, when I go to import the file, KCacheGrind just displays an 'Unknown File Format' error in the status bar and sits there displaying nothing. Is there something speci...

does cProfile profile calls inside threads?

I ran cprofile on a bit of code, which among other things spawns several threads that do most of the work. When I looked at the output of the profiling, I see no logging of all the functions that were called inside the threads. I am sure they were called, as they do stuff that is easy to see such as writing to a DB etc. Does cProfile no...

Python Profiling In Windows, How do you ignore Builtin Functions

I have not been capable of finding this anywhere online. I was looking to find out using a profiler how to better optimize my code, and when sorting by which functions use up the most time cumulatively, things like str(), print, and other similar widely used functions eat up much of the profile. What is the best way to profile a python ...

Where is my python script spending time? Is there "missing time" in my cprofile / pstats trace?

I am attempting to profile a long running python script. The script does some spatial analysis on raster GIS data set using the gdal module. The script currently uses three files, the main script which loops over the raster pixels called find_pixel_pairs.py, a simple cache in lrucache.py and some misc classes in utils.py. I have profi...

Serious overhead in Python cProfile?

Hi expert Pythonists out there, I am starting to use cProfile so as to have a more detailed timing information on my program. However, it's quite disturbing to me that there's a significant overhead. Any idea why cProfile reported 7 seconds while time module only reported 2 seconds in the code below? # a simple function def f(a, b): c...

Can't figure out how to invoke cProfile inside of a program

Hey guys, Sorry for the beginner question, but I can't figure out cProfile (I'm really new to Python) I can run it via my terminal with: python -m cProfile myscript.py But I need to run it on a webserver, so I'd like to put the command within the script it will look at. How would I do this? I've seen stuff using terms like __init__ ...

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! ...

How can I speed up fetching pages with urllib2 in python?

I have a script that fetches several web pages and parses the info. (An example can be seen at http://bluedevilbooks.com/search/?DEPT=MATH&CLASS=103&SEC=01 ) I ran cProfile on it, and as I assumed, urlopen takes up a lot of time. Is there a way to fetch the pages faster? Or a way to fetch several pages at once? I'll do whatever...

Python cProfile: how to filter out specific calls from the profiling data?

I've started profiling a script which has many sleep(n) statements. All in all, I get over 99% of the run time spent sleeping. Nevertheless, it occasionally runs into performance problems during the time that it does real work but the relevant, interesting profiling data becomes very difficult to identify when e.g. using kcachegrind. Is...

Is there a high-level profiling module for Python?

I want to profile my Python code. I am well-aware of cProfile, and I use it, but it's too low-level. (For example, there isn't even a straightforward way to catch the return value from the function you're profiling.) One of the things I would like to do: I want to take a function in my program and set it to be profiled on the fly while ...

What is this cProfile result telling me I need to fix?

I would like to improve the performance of a Python script and have been using cProfile to generate a performance report: python -m cProfile -o chrX.prof ./bgchr.py ...args... I opened this chrX.prof file with Python's pstats and printed out the statistics: Python 2.7 (r27:82500, Oct 5 2010, 00:24:22) [GCC 4.1.2 20080704 (Red Hat 4...

Profile python program that forks itself as a daemon

Is it possible to run cprofile on a mult-threaded python program that forks itself into a daemon process? I know you can make it work on multi thread, but I haven't seen anything on profiling a daemon. ...