From 8adc71ce068aad32f9d7d47d717dc0a36a8561ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jure=20=C5=A0orn?= Date: Wed, 29 Nov 2023 23:11:08 +0100 Subject: [PATCH 001/348] Profiling --- README.md | 29 ++++++++++++++--------------- index.html | 33 ++++++++++++++++----------------- parse.js | 23 +++++++++++------------ 3 files changed, 41 insertions(+), 44 deletions(-) diff --git a/README.md b/README.md index b8ab554e4..0a74eff70 100644 --- a/README.md +++ b/README.md @@ -2605,12 +2605,12 @@ def main(): b = set(range(10000)) main()' > test.py $ kernprof -lv test.py -Line # Hits Time Per Hit % Time Line Contents -======================================================= - 1 @profile - 2 def main(): - 3 1 219.0 219.0 31.1 a = list(range(10000)) - 4 1 487.0 487.0 68.9 b = set(range(10000)) +Line # Hits Time Per Hit % Time Line Contents +============================================================== + 1 @profile + 2 def main(): + 3 1 253.4 253.4 32.2 a = list(range(10000)) + 4 1 534.1 534.1 67.8 b = set(range(10000)) ``` ### Call and Flame Graphs @@ -2624,15 +2624,14 @@ $ snakeviz test.prof ### Sampling and Memory Profilers ```text -+--------------+-------------------------------+------------+----------+------+ -| pip3 install | How to run | Target | Type | Live | -+--------------+-------------------------------+------------+----------+------+ -| py-spy | py-spy top -- python3 test.py | CPU | Sampling | Yes | -| pyinstrument | pyinstrument test.py | CPU | Sampling | No | -| scalene | scalene test.py | CPU+Memory | Sampling | No | -| memray | memray run --live test.py | Memory | Tracing | Yes | -| filprofiler | fil-profile run test.py | Memory | Tracing | No | -+--------------+-------------------------------+------------+----------+------+ ++--------------+----------+------------+-------------------------------+------+ +| pip3 install | Type | Target | How to run | Live | ++--------------+----------+------------+-------------------------------+------+ +| pyinstrument | Sampling | CPU | pyinstrument test.py | No | +| py-spy | Sampling | CPU | py-spy top -- python3 test.py | Yes | +| scalene | Sampling | CPU+Memory | scalene test.py | No | +| memray | Tracing | Memory | memray run --live test.py | Yes | ++--------------+----------+------------+-------------------------------+------+ ``` diff --git a/index.html b/index.html index 2c0eddd4c..4c6aada0b 100644 --- a/index.html +++ b/index.html @@ -54,7 +54,7 @@
- +
@@ -2130,12 +2130,12 @@

Format

Call and Flame Graphs

$ pip3 install gprof2dot snakeviz; apt/brew install graphviz
@@ -2145,15 +2145,14 @@ 

Format

Sampling and Memory Profilers

┏━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━┯━━━━━━━━━━┯━━━━━━┓
-┃ pip3 install │          How to run           │   Target   │   Type   │ Live ┃
-┠──────────────┼───────────────────────────────┼────────────┼──────────┼──────┨
-┃ py-spy       │ py-spy top -- python3 test.py │    CPU     │ Sampling │ Yes  ┃
-┃ pyinstrument │ pyinstrument test.py          │    CPU     │ Sampling │ No   ┃
-┃ scalene      │ scalene test.py               │ CPU+Memory │ Sampling │ No   ┃
-┃ memray       │ memray run --live test.py     │   Memory   │ Tracing  │ Yes  ┃
-┃ filprofiler  │ fil-profile run test.py       │   Memory   │ Tracing  │ No   ┃
-┗━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━┷━━━━━━━━━━┷━━━━━━┛
+

Sampling and Memory Profilers

┏━━━━━━━━━━━━━━┯━━━━━━━━━━┯━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┯━━━━━━┓
+┃ pip3 install │   Type   │   Target   │          How to run           │ Live ┃
+┠──────────────┼──────────┼────────────┼───────────────────────────────┼──────┨
+┃ pyinstrument │ Sampling │    CPU     │ pyinstrument test.py          │  ×   ┃
+┃ py-spy       │ Sampling │    CPU     │ py-spy top -- python3 test.py │  ✓   ┃
+┃ scalene      │ Sampling │ CPU+Memory │ scalene test.py               │  ×   ┃
+┃ memray       │ Tracing  │   Memory   │ memray run --live test.py     │  ✓   ┃
+┗━━━━━━━━━━━━━━┷━━━━━━━━━━┷━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┷━━━━━━┛
 

#NumPy

Array manipulation mini-language. It can run up to one hundred times faster than the equivalent Python code. An even faster alternative that runs on a GPU is called CuPy.

# $ pip3 install numpy
@@ -2926,7 +2925,7 @@ 

Format