From 6332382b6ca6e7ac11dc8026d21332f99920de75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jure=20=C5=A0orn?= Date: Sun, 30 Dec 2018 02:36:59 +0100 Subject: [PATCH] Profile --- README.md | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 11df6dc..0463bf7 100644 --- a/README.md +++ b/README.md @@ -1423,14 +1423,16 @@ timeit('"-".join(str(a) for a in range(100))', number=10000, globals=globals()) ``` -### PyCallGraph +### Call Graph #### Generates a PNG image of call graph and highlights the bottlenecks. ```python # $ pip3 install pycallgraph -import pycallgraph -graph = pycallgraph.output.GraphvizOutput() -graph.output_file = get_filename() -with pycallgraph.PyCallGraph(output=graph): +from pycallgraph import output, PyCallGraph +from datetime import datetime +graph = output.GraphvizOutput() +time_str = datetime.now().strftime('%Y%m%d%H%M%S') +graph.output_file = f'profile-{time_str}.png' +with PyCallGraph(output=graph): ```