profiling

Python line-by-line memory profiler?

Python line-by-line memory profiler? Question: I’m looking to generate, from a large Python codebase, a summary of heap usage or memory allocations over the course of a function’s run. I’m familiar with heapy, and it’s served me well for taking “snapshots” of the heap at particular points in my code, but I’ve found it difficult …

Total answers: 2

Searching for a string in a large text file – profiling various methods in python

Searching for a string in a large text file – profiling various methods in python Question: This question has been asked many times. After spending some time reading the answers, I did some quick profiling to try out the various methods mentioned previously… I have a 600 MB file with 6 million lines of strings …

Total answers: 6

How can you get the call tree with Python profilers?

How can you get the call tree with Python profilers? Question: I used to use a nice Apple profiler that is built into the System Monitor application. As long as your C++ code was compiled with debug information, you could sample your running application and it would print out an indented tree telling you what …

Total answers: 4

How can I profile Python code line-by-line?

How can I profile Python code line-by-line? Question: I’ve been using cProfile to profile my code, and it’s been working great. I also use gprof2dot.py to visualize the results (makes it a little clearer). However, cProfile (and most other Python profilers I’ve seen so far) seem to only profile at the function-call level. This causes …

Total answers: 5

Profiling python C extensions

Profiling python C extensions Question: I have developed a python C-extension that receives data from python and compute some cpu intensive calculations. It’s possible to profile the C-extension? The problem here is that writing a sample test in C to be profiled would be challenging because the code rely on particular inputs and data structures …

Total answers: 5

Using cProfile results with KCacheGrind

Using cProfile results with KCacheGrind Question: 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 …

Total answers: 5

accurately measure time python function takes

accurately measure time python function takes Question: I need to measure the time certain parts of my program take (not for debugging but as a feature in the output). Accuracy is important because the total time will be a fraction of a second. I was going to use the time module when I came across …

Total answers: 7

Accurate timing of functions in python

Accurate timing of functions in python Question: I’m programming in python on windows and would like to accurately measure the time it takes for a function to run. I have written a function “time_it” that takes another function, runs it, and returns the time it took to run. def time_it(f, *args): start = time.clock() f(*args) …

Total answers: 7

Profiling in Python: Who called the function?

Profiling in Python: Who called the function? Question: I’m profiling in Python using cProfile. I found a function that takes a lot of CPU time. How do I find out which function is calling this heavy function the most? EDIT: I’ll settle for a workaround: Can I write a Python line inside that heavy function …

Total answers: 8

How can I profile a multithread program in Python?

How can I profile a multithread program in Python? Question: I’m developing an inherently multithreaded module in Python, and I’d like to find out where it’s spending its time. cProfile only seems to profile the main thread. Is there any way of profiling all threads involved in the calculation? Asked By: rog || Source Answers: …

Total answers: 7