python Programming Glossary: cprofile.run
Python multiprocess profiling http://stackoverflow.com/questions/11041683/python-multiprocess-profiling 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.. test num time.sleep 3 print 'Worker ' num def worker num cProfile.runctx 'test num ' globals locals 'prof d.prof' num if __name__..
Is there any simple way to benchmark python script? http://stackoverflow.com/questions/1593019/is-there-any-simple-way-to-benchmark-python-script example from the official docs import cProfile import re cProfile.run 're.compile foo bar ' Which will give you 197 function calls..
How to filter (or replace) unicode characters that would take more than 3 bytes in UTF-8? http://stackoverflow.com/questions/3220031/how-to-filter-or-replace-unicode-characters-that-would-take-more-than-3-bytes unicode_string print ' ' 10 ' filter_using_re ' ' ' 10 cProfile.run 'repeat_test filter_using_re test_string ' print ' ' 10 ' filter_using_python.. test_string ' print ' ' 10 ' filter_using_python ' ' ' 10 cProfile.run 'repeat_test filter_using_python test_string ' #print test_string.encode..
Improving pure Python prime sieve by recurrence formula http://stackoverflow.com/questions/3285443/improving-pure-python-prime-sieve-by-recurrence-formula cProfile.Profile.bias 4e 6 for test in rwh_primes1 primes cProfile.run test numprimes Profiling not so much difference between versions..
Memoization Handler http://stackoverflow.com/questions/3377258/memoization-handler factorial d num return handler.memo factorial d num cProfile.run 'factorialTwice ' cProfile.run 'memoizedFactorial ' python.. factorial d num cProfile.run 'factorialTwice ' cProfile.run 'memoizedFactorial ' python dynamic programming memoization..
App Engine: Is time.sleep() counting towards my quotas? http://stackoverflow.com/questions/4254678/app-engine-is-time-sleep-counting-towards-my-quotas test import cProfile import time def foo time.sleep 3 cProfile.run 'foo ' Which gave me the following output 4 function calls in..
How can you profile a Python script? http://stackoverflow.com/questions/582336/how-can-you-profile-a-python-script code or from the interpreter like this import cProfile cProfile.run 'foo ' Even more usefully you can invoke the cProfile when running..
Optimizing Python Code [closed] http://stackoverflow.com/questions/7165465/optimizing-python-code can run a function in cProfile like this import cProfile cProfile.run 'myFunction ' 'myFunction.profile' Then to view the results..
Profiled performance of len(set) vs. set.__len__() in Python 3 http://stackoverflow.com/questions/8778691/profiled-performance-of-lenset-vs-set-len-in-python-3 def main s set lenA s lenB s if __name__ __main__ cProfile.run main stats According to profiler's stats below lenA seems to..
Accurate timing of functions in python http://stackoverflow.com/questions/889900/accurate-timing-of-functions-in-python my time_it function returns an average of 2.5 ms while the cProfile.run 'f ' returns and average of 7.0 ms. I figured my function would..
|