File tree Expand file tree Collapse file tree 1 file changed +16
-17
lines changed Expand file tree Collapse file tree 1 file changed +16
-17
lines changed Original file line number Diff line number Diff line change @@ -1339,7 +1339,23 @@ duration = time() - start_time
1339
1339
from timeit import timeit
1340
1340
timeit(' "-".join(str(n) for n in range(100))' ,
1341
1341
number = 10000 , globals = globals ())
1342
+ ```
1342
1343
1344
+ #### Generates a PNG image of call graph and highlights the bottlenecks:
1345
+ ``` python
1346
+ # $ pip3 install pycallgraph
1347
+ import pycallgraph
1348
+ graph = pycallgraph.output.GraphvizOutput()
1349
+ graph.output_file = get_filename()
1350
+ with pycallgraph.PyCallGraph(output = graph):
1351
+ < code_to_be_profiled>
1352
+ ```
1353
+
1354
+ ``` python
1355
+ def get_filename ():
1356
+ from datetime import datetime
1357
+ time_str = datetime.now().strftime(' %Y%m%d %H%M%S' )
1358
+ return f ' profile- { time_str} .png '
1343
1359
```
1344
1360
1345
1361
#### Decorator for timing function execution:
@@ -1399,23 +1415,6 @@ def tracer(func):
1399
1415
return traced_func
1400
1416
```
1401
1417
1402
- #### Generates a PNG image of call graph and highlights the bottlenecks:
1403
- ``` python
1404
- # $ pip3 install pycallgraph
1405
- import pycallgraph
1406
- graph = pycallgraph.output.GraphvizOutput()
1407
- graph.output_file = get_filename()
1408
- with pycallgraph.PyCallGraph(output = graph):
1409
- < code_to_be_profiled>
1410
- ```
1411
-
1412
- ``` python
1413
- def get_filename ():
1414
- from datetime import datetime
1415
- time_str = datetime.now().strftime(' %Y%m%d %H%M%S' )
1416
- return f ' profile- { time_str} .png '
1417
- ```
1418
-
1419
1418
1420
1419
Progress Bar
1421
1420
------------
You can’t perform that action at this time.
0 commit comments