Re: [Zope] ZopeProfiler and Kcachegrind, how to convert statistics files ?
Sebastien Douche a écrit : > On Wed, Jan 28, 2009 at 16:56, Jean-Michel FRANCOIS > wrote: > >> Is someone has try to use ZopeProfiler with KCacheGrind ? I would like >> to try KCachegrind because i found xdot very slow. >> >> I have started to read the code of ZopeProfiler and i have discovered >> the world of profiling file format. It seems that ZopeProfiler save it's >> file in pstats format. So i need to convert those file to calltree >> format. But all scripts i have tryed has failed: >> >> * pyprof2calltree >> * lsprofcalltree.py >> * hotshot2calltree >> >> So am i on the wrong way ? Do i need to fix one of these script ? Are >> you using on of them ? >> > > Maybe try this? > http://pypi.python.org/pypi/profilestats/1.0 > > > About those 10 lines of codes: It use the 'with' keyword so it is not compatible with python2.4 & Zope2.9 It use pyprof2calltree to convert stats to calltree (kcachegrind) It less flexible than ZopeProfiler (no configuration, no way to save multiple stats (filename is hardcoded)) You must modify the code (it s a decorator) So it's not help me in this case but thanks for pointing me out this decorator, it can help me for other use cases JeanMichel FRANCOIS Makina-Corpus ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] ZopeProfiler and Kcachegrind, how to convert statistics files ?
On Wed, Jan 28, 2009 at 16:56, Jean-Michel FRANCOIS wrote: > Is someone has try to use ZopeProfiler with KCacheGrind ? I would like > to try KCachegrind because i found xdot very slow. > > I have started to read the code of ZopeProfiler and i have discovered > the world of profiling file format. It seems that ZopeProfiler save it's > file in pstats format. So i need to convert those file to calltree > format. But all scripts i have tryed has failed: > > * pyprof2calltree > * lsprofcalltree.py > * hotshot2calltree > > So am i on the wrong way ? Do i need to fix one of these script ? Are > you using on of them ? Maybe try this? http://pypi.python.org/pypi/profilestats/1.0 -- Sebastien Douche ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] ZopeProfiler and Kcachegrind, how to convert statistics files ?
It's done, i m now able to use KCachegrind with ZopeProfiler. I have patched pyprof2calltree to work with python2.4: diff -U 3 -H -d -r -N -- pyprof2calltree-1.1.0-py2.4.egg/pyprof2calltree.py pyprof2calltree-1.1.0-py2.4.egg.NEW//pyprof2calltree.py --- pyprof2calltree-1.1.0-py2.4.egg/pyprof2calltree.py2008-12-21 19:14:42.0 +0100 +++ pyprof2calltree-1.1.0-py2.4.egg.NEW//pyprof2calltree.py 2009-01-29 17:15:05.0 +0100 @@ -26,7 +26,18 @@ take a previously recorded instance of the pstats.Stats class. """ -import cProfile +try: +import cProfile +except ImportError: +#BBB for python2.4 +import profile as cProfile +def label(code): +if isinstance(code, str): +return ('~', 0, code) # built-in functions ('~' sorts at the end) +else: +return (code.co_filename, code.co_firstlineno, code.co_name) +cProfile.label = label + import pstats import optparse import os But something don't work : the call_info variable is not a sequence but a integer, so i have fixed it like that: @@ -175,9 +186,9 @@ print >> out_file, 'cfn=%s %s:%d' % ( co_name, co_filename, co_firstlineno) print >> out_file, 'cfi=%s' % (co_filename,) -print >> out_file, 'calls=%d %d' % (call_info[0], co_firstlineno) +print >> out_file, 'calls=%d %d' % (call_info, co_firstlineno) -totaltime = int(call_info[3] * 1000) +totaltime = int(call_info * 1000) print >> out_file, '%d %d' % (lineno, totaltime) def main(): Jean-Michel FRANCOIS a écrit : > Dieter Maurer a écrit : > >> Jean-Michel FRANCOIS wrote at 2009-1-28 16:56 +0100: >> >> >>> Is someone has try to use ZopeProfiler with KCacheGrind ? I would like >>> to try KCachegrind because i found xdot very slow. >>> >>> I have started to read the code of ZopeProfiler and i have discovered >>> the world of profiling file format. It seems that ZopeProfiler save it's >>> file in pstats format. So i need to convert those file to calltree >>> format. But all scripts i have tryed has failed: >>> >>> * pyprof2calltree >>> * lsprofcalltree.py >>> * hotshot2calltree >>> >>> So am i on the wrong way ? Do i need to fix one of these script ? Are >>> you using on of them ? >>> >>> >> You could try "pyprof2calltree" from the Python interpreter in >> the following way: >> >> from marshal import load >> from pyprof2calltree import visualize # or convert >> stats = load(open(name_of_saved_file, 'rb')) >> visualize(stats) >> >> >> Not sure whether it will work (it probably will when "pyprof2calltree" does >> not expect a more modern 'pstats' format). >> >> >> >> >> > I have try this one. First issue, it assume you are using a Python2.5 > (cProfile is new in Python2.5 but assume the same API) so i have change > the import > > import profile as cProfile > > Now got a new problem when trying visualize: > > visualize(stats) > Traceback (most recent call last): > File "", line 1, in ? > File > "/home/toutpt/temp/profiling/lib/python2.4/site-packages/pyprof2calltree-1.1.0-py2.4.egg/pyprof2calltree.py", > line 256, in visualize > converter = CalltreeConverter(profiling_data) > File > "/home/toutpt/temp/profiling/lib/python2.4/site-packages/pyprof2calltree-1.1.0-py2.4.egg/pyprof2calltree.py", > line 117, in visualize > self.output(f) > File > "/home/toutpt/temp/profiling/lib/python2.4/site-packages/pyprof2calltree-1.1.0-py2.4.egg/pyprof2calltree.py", > line 104, in output > self._print_summary() > File > "/home/toutpt/temp/profiling/lib/python2.4/site-packages/pyprof2calltree-1.1.0-py2.4.egg/pyprof2calltree.py", > line 134, in _print_summary > print entry > AttributeError: 'tuple' object has no attribute 'totaltime' > > > ___ > Zope maillist - Zope@zope.org > http://mail.zope.org/mailman/listinfo/zope > ** No cross posts or HTML encoding! ** > (Related lists - > http://mail.zope.org/mailman/listinfo/zope-announce > http://mail.zope.org/mailman/listinfo/zope-dev ) > ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] ZopeProfiler and Kcachegrind, how to convert statistics files ?
Dieter Maurer a écrit : > Jean-Michel FRANCOIS wrote at 2009-1-28 16:56 +0100: > >> Is someone has try to use ZopeProfiler with KCacheGrind ? I would like >> to try KCachegrind because i found xdot very slow. >> >> I have started to read the code of ZopeProfiler and i have discovered >> the world of profiling file format. It seems that ZopeProfiler save it's >> file in pstats format. So i need to convert those file to calltree >> format. But all scripts i have tryed has failed: >> >> * pyprof2calltree >> * lsprofcalltree.py >> * hotshot2calltree >> >> So am i on the wrong way ? Do i need to fix one of these script ? Are >> you using on of them ? >> > > You could try "pyprof2calltree" from the Python interpreter in > the following way: > > from marshal import load > from pyprof2calltree import visualize # or convert > stats = load(open(name_of_saved_file, 'rb')) > visualize(stats) > > > Not sure whether it will work (it probably will when "pyprof2calltree" does > not expect a more modern 'pstats' format). > > > > I have try this one. First issue, it assume you are using a Python2.5 (cProfile is new in Python2.5 but assume the same API) so i have change the import import profile as cProfile Now got a new problem when trying visualize: >>> visualize(stats) Traceback (most recent call last): File "", line 1, in ? File "/home/toutpt/temp/profiling/lib/python2.4/site-packages/pyprof2calltree-1.1.0-py2.4.egg/pyprof2calltree.py", line 256, in visualize converter = CalltreeConverter(profiling_data) File "/home/toutpt/temp/profiling/lib/python2.4/site-packages/pyprof2calltree-1.1.0-py2.4.egg/pyprof2calltree.py", line 117, in visualize self.output(f) File "/home/toutpt/temp/profiling/lib/python2.4/site-packages/pyprof2calltree-1.1.0-py2.4.egg/pyprof2calltree.py", line 104, in output self._print_summary() File "/home/toutpt/temp/profiling/lib/python2.4/site-packages/pyprof2calltree-1.1.0-py2.4.egg/pyprof2calltree.py", line 134, in _print_summary print entry AttributeError: 'tuple' object has no attribute 'totaltime' ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] ZopeProfiler and Kcachegrind, how to convert statistics files ?
Jean-Michel FRANCOIS wrote at 2009-1-28 16:56 +0100: >Is someone has try to use ZopeProfiler with KCacheGrind ? I would like >to try KCachegrind because i found xdot very slow. > >I have started to read the code of ZopeProfiler and i have discovered >the world of profiling file format. It seems that ZopeProfiler save it's >file in pstats format. So i need to convert those file to calltree >format. But all scripts i have tryed has failed: > >* pyprof2calltree >* lsprofcalltree.py >* hotshot2calltree > >So am i on the wrong way ? Do i need to fix one of these script ? Are >you using on of them ? You could try "pyprof2calltree" from the Python interpreter in the following way: from marshal import load from pyprof2calltree import visualize # or convert stats = load(open(name_of_saved_file, 'rb')) visualize(stats) Not sure whether it will work (it probably will when "pyprof2calltree" does not expect a more modern 'pstats' format). -- Dieter ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )