Skip to content
Snippets Groups Projects
Commit cd96ea17 authored by Martin Lange's avatar Martin Lange
Browse files

convert profiling output to CSV

parent ede3c38e
No related branches found
No related tags found
1 merge request!221Benchmark full run, profiling
import io
import os
import pstats
def _convert_to_csv(in_path, out_path):
result = io.StringIO()
pstats.Stats(in_path, stream=result).print_stats()
result = result.getvalue()
result = "ncalls" + result.split("ncalls")[-1]
result = "\n".join(
[",".join(line.rstrip().split(None, 5)) for line in result.split("\n")]
)
with open(out_path, "w+") as f:
f.write(result)
f.close()
if __name__ == "__main__":
path = "prof/"
for file in os.listdir(path):
if file.endswith(".pstats"):
in_file = os.path.join(path, file)
out_file = os.path.join(path, file.replace(".pstats", ".csv"))
_convert_to_csv(in_file, out_file)
echo TEST
echo Profiling...
mkdir -p prof
python -m cProfile -o prof/simple_run.pstats benchmarks/profiling/simple_run.py
gprof2dot --colour-nodes-by-selftime -f pstats prof/simple_run.pstats > prof/simple_run.dot
dot -Tsvg -o prof/simple_run.svg prof/simple_run.dot
dot -Tpng -o prof/simple_run.png prof/simple_run.dot
python benchmarks/pstats_to_csv.py
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment