def _save_as_CALLGRIND(self, path):
header = """<STR_LIT>""" %('<STR_LIT>', os.getpid(), '<STR_LIT:U+0020>'.join(sys.argv))<EOL>lines = [header]<EOL>file_ids = ['<STR_LIT>']<EOL>func_ids = ['<STR_LIT>']<EOL>for func_stat in self:<EOL><INDENT>file_ids += [ '<STR_LIT>' % (func_stat.index, func_stat.module) ]<EOL>func_ids += [ '<STR_LIT>' % (func_stat.index, func_stat.name, func_stat.module, func_stat.lineno) ]<EOL><DEDENT>lines += file_ids + func_ids<EOL>for func_stat in self:<EOL><INDENT>func_stats = [ '<STR_LIT>',<EOL>'<STR_LIT>' % func_stat.index,<EOL>'<STR_LIT>' % func_stat.index]<EOL>func_stats += [ '<STR_LIT>' % (func_stat.lineno, int(func_stat.tsub * <NUM_LIT>)) ]<EOL>for child in func_stat.children:<EOL><INDENT>func_stats += [ '<STR_LIT>' % child.index,<EOL>'<STR_LIT>' % child.index,<EOL>'<STR_LIT>' % child.ncall,<EOL>'<STR_LIT>' % int(child.ttot * <NUM_LIT>)<EOL>]<EOL><DEDENT>lines += func_stats<EOL><DEDENT>file = open(path, "<STR_LIT:w>")<EOL>try:<EOL><INDENT>file.write('<STR_LIT:\n>'.join(lines))                <EOL><DEDENT>finally:<EOL><INDENT>file.close()<EOL><DEDENT>
Writes all the function stats in a callgrind-style format to the given
file. (stdout by default)