From ae481ede5f49e916f80e2cc671a33f5f64c5b0e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jure=20=C5=A0orn?= Date: Fri, 28 Dec 2018 04:05:31 +0100 Subject: [PATCH] Fixed last commit --- README.md | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index a0e88ff..53d0d59 100644 --- a/README.md +++ b/README.md @@ -1339,7 +1339,23 @@ duration = time() - start_time from timeit import timeit timeit('"-".join(str(n) for n in range(100))', number=10000, globals=globals()) +``` +#### 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): + +``` + +```python +def get_filename(): + from datetime import datetime + time_str = datetime.now().strftime('%Y%m%d%H%M%S') + return f'profile-{time_str}.png' ``` #### Decorator for timing function execution: @@ -1399,23 +1415,6 @@ def tracer(func): return traced_func ``` -#### 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): - -``` - -```python -def get_filename(): - from datetime import datetime - time_str = datetime.now().strftime('%Y%m%d%H%M%S') - return f'profile-{time_str}.png' -``` - Progress Bar ------------