[Zope] ZopeProfiler and Kcachegrind, how to convert statistics files ?

Jean-Michel FRANCOIS jeanmichel.francois at makina-corpus.com
Thu Jan 29 06:27:26 EST 2009


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 "<stdin>", 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'




More information about the Zope mailing list