I am using Python\'s hotshot profiler: http://docs.python.org/2/library/hotshot.html
It shows how to print the stats:
stats.print_stats(20)
Stats takes an optional 'stream' argument. Simply open a file and pass the open file object to the Stats constructor as shown below. From that point any call to print_stats() will output to the stream you passed into the constructor. Hope this helps. :)
with open('path/to/output', 'w') as stream:
stats = pstats.Stats('path/to/input', stream=stream)
stats.print_stats()