From a0df25268bae3f4a26bddbea5bbecec6412c1e48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jure=20=C5=A0orn?= Date: Tue, 5 Dec 2023 00:55:48 +0100 Subject: [PATCH] Profiling --- README.md | 9 +++++---- index.html | 13 +++++++------ 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 0a74eff..5a69928 100644 --- a/README.md +++ b/README.md @@ -2604,7 +2604,7 @@ def main(): a = list(range(10000)) b = set(range(10000)) main()' > test.py -$ kernprof -lv test.py +$ kernprof --line-by-line --view test.py Line # Hits Time Per Hit % Time Line Contents ============================================================== 1 @profile @@ -2615,10 +2615,11 @@ Line # Hits Time Per Hit % Time Line Contents ### Call and Flame Graphs ```text -$ pip3 install gprof2dot snakeviz; apt/brew install graphviz -$ tail -n 4 test.py > test.py +$ apt/brew install graphviz && pip3 install gprof2dot snakeviz +$ tail --lines=4 test.py > test.py $ python3 -m cProfile -o test.prof test.py -$ gprof2dot -f pstats test.prof | dot -T png -o test.png; xdg-open/open test.png +$ gprof2dot --format=pstats test.prof | dot -T png -o test.png +$ xdg-open/open test.png $ snakeviz test.prof ``` diff --git a/index.html b/index.html index 4c6aada..4e72642 100644 --- a/index.html +++ b/index.html @@ -54,7 +54,7 @@
- +
@@ -2129,7 +2129,7 @@ def main(): a = list(range(10000)) b = set(range(10000)) main()' > test.py -$ kernprof -lv test.py +$ kernprof --line-by-line --view test.py Line # Hits Time Per Hit % Time Line Contents ============================================================== 1 @profile @@ -2138,10 +2138,11 @@ Line # Hits Time Per Hit % Time Line Contents 4 1 534.1 534.1 67.8 b = set(range(10000)) -

Call and Flame Graphs

$ pip3 install gprof2dot snakeviz; apt/brew install graphviz
-$ tail -n 4 test.py > test.py
+

Call and Flame Graphs

$ apt/brew install graphviz && pip3 install gprof2dot snakeviz
+$ tail --lines=4 test.py > test.py
 $ python3 -m cProfile -o test.prof test.py
-$ gprof2dot -f pstats test.prof | dot -T png -o test.png; xdg-open/open test.png
+$ gprof2dot --format=pstats test.prof | dot -T png -o test.png
+$ xdg-open/open test.png
 $ snakeviz test.prof
 
@@ -2925,7 +2926,7 @@ $ deactivate # Deactivates the activ