-1

I am currently profiling some python code like so:

import cProfile
cProfile.runctx('self._Foo ()', globals(), locals(), 'c:/restats.txt')

def Foo(self):
    stuff

The code runs successfuly, outputs no exception. However my restats.txt looks like this:

SomeFunc( i i gÇZ3a/­?gÇZ3a/­?0( s; C:\SomeFolder\bar.pyiL t

Basically it is 150 lines of garbage characters with random paths and function names mixed in.

What could be the issue? Am I using this correctly? The python file is being loaded in through Maya if that makes a differance.

marsh
  • 2,592
  • 5
  • 29
  • 53

2 Answers2

2

Please read the documentation for what to do after you have collected the trace information. I believe you will need to use pstats.Stats to extract the information you need.

holdenweb
  • 33,305
  • 7
  • 57
  • 77
1

The file is not meant to be human-readable. As described in the documentation, you can use the pstats module to load the file and explore the profiling data.

BrenBarn
  • 242,874
  • 37
  • 412
  • 384