cprofile

What does {method 'poll' of 'select.poll'…} mean in cprofile output?

What does {method 'poll' of 'select.poll'…} mean in cprofile output? Question: I have a flask app that I’m trying to profile (I’m new to this). When I ran it, I had this result: 3327 function calls (3247 primitive calls) in 7.350 seconds Ordered by: cumulative time ncalls tottime percall cumtime percall filename:lineno(function) 7/1 0.000 0.000 …

Total answers: 1

saving cProfile results to readable external file

saving cProfile results to readable external file Question: I am using cProfile try to profile my codes: pr = cProfile.Profile() pr.enable() my_func() # the code I want to profile pr.disable() pr.print_stats() However, the results are too long and cannot be fully displayed in the Spyder terminal (the function calls which take the longest time to …

Total answers: 5

Python cProfile results: two numbers for ncalls

Python cProfile results: two numbers for ncalls Question: I just recently began profiling a server application that I’ve been working on, trying to find out where some excess processor time is being spent and looking for ways to make things smoother. Overall, I think I’ve got a good hang of using cProfile and pstats, but …

Total answers: 1

Python getting meaningful results from cProfile

Python getting meaningful results from cProfile Question: I have a Python script in a file which takes just over 30 seconds to run. I am trying to profile it as I would like to cut down this time dramatically. I am trying to profile the script using cProfile, but essentially all it seems to be …

Total answers: 1

Python multiprocess profiling

Python multiprocess profiling Question: I want to profile a simple multi-process Python script. I tried this code: import multiprocessing import cProfile import time def worker(num): time.sleep(3) print ‘Worker:’, num if __name__ == ‘__main__’: for i in range(5): p = multiprocessing.Process(target=worker, args=(i,)) cProfile.run(‘p.start()’, ‘prof%d.prof’ %i) I’m starting 5 processes and therefore cProfile generates 5 different files. …

Total answers: 3

Sort cProfile output by percall when profiling a Python script

Sort cProfile output by percall when profiling a Python script Question: I’m using python -m cProfile -s calls myscript.py python -m cProfile -s percall myscript.py does not work. The Python documentation says “Look in the Stats documentation for valid sort values.”: http://docs.python.org/library/profile.html#module-cProfile, which I cannot find. Asked By: Brandon O'Rourke || Source Answers: -s only …

Total answers: 1

cProfile for Python does not recognize Function name

cProfile for Python does not recognize Function name Question: I have a function in an app called email which I want to profile. When I try to do something like this, it blows up from django.core.management import BaseCommand import cProfile class Command(BaseCommand): def handle(self, *args, **options): from email.modname import send_email cProfile.run(‘send_email(user_id=1, city_id=4)’) When I run …

Total answers: 1

cProfile saving data to file causes jumbles of characters

cProfile saving data to file causes jumbles of characters Question: I am using cProfile on a module named bot4CA.py so in the console I type: python -m cProfile -o thing.txt bot4CA.py After the module runs and exits, it creates a file named thing.txt and when I open it, there is some information there, and the …

Total answers: 3

profiling a method of a class in Python using cProfile?

profiling a method of a class in Python using cProfile? Question: I’d like to profile a method of a function in Python, using cProfile. I tried the following: import cProfile as profile # Inside the class method… profile.run(“self.myMethod()”, “output_file”) But it does not work. How can I call a self.method with “run”? Asked By: user248237 …

Total answers: 5

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

How can I speed up fetching pages with urllib2 in python? Question: 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 …

Total answers: 11