Difference between revisions of "Development Team/Performance"
Jump to navigation
Jump to search
(New page: Just a quick dump of the snippets I use for profiling: First use a system-wide profiler like sysprof Next, profile python code, open the output with kcachegrind: import os import cPro...) |
|||
Line 1: | Line 1: | ||
+ | <noinclude>{{ GoogleTrans-en | es =show | bg =show | zh-CN =show | zh-TW =show | hr =show | cs =show | da =show | nl =show | fi =show | fr =show | de =show | el =show | hi =show | it =show | ja =show | ko =show | no =show | pl =show | pt =show | ro =show | ru =show | sv =show }}</noinclude> | ||
Just a quick dump of the snippets I use for profiling: | Just a quick dump of the snippets I use for profiling: | ||
Revision as of 00:44, 12 June 2008
Just a quick dump of the snippets I use for profiling:
First use a system-wide profiler like sysprof
Next, profile python code, open the output with kcachegrind:
import os import cProfile import lsprofcalltree # http://www.gnome.org/~johan/lsprofcalltree.py profiler = cProfile.Profile() profiler.enable() ### code to profile ### profiler.disable() k = lsprofcalltree.KCacheGrind(profiler) data = open('/tmp/import.kgrind', 'w+') k.output(data) data.close()
Check for leaks:
import gobject gobject.timeout_add(10000, self._log_mem_usage) def _log_mem_usage(self): import analysis, os, gc for obj in gc.get_objects(): if hasattr(obj, '__class__') and obj.__class__.__name__.find('ChooserListView') > -1: logging.debug(obj) for i in range(0, 10): gc.collect() logging.debug('mem: %i' % analysis.Analysis(os.getpid()).ApproxRealMemoryUsage()) return True
Rendering time of a widget/window:
def do_expose_event(self, event): import time t = time.time() hippo.Canvas.do_expose_event(self, event) logging.debug('listview expose event: %r' % (time.time() - t))