Browse Source

Profiling

pull/170/head
Jure Šorn 1 year ago
parent
commit
8adc71ce06
3 changed files with 41 additions and 44 deletions
  1. 29
      README.md
  2. 33
      index.html
  3. 23
      parse.js

29
README.md

@ -2605,12 +2605,12 @@ def main():
b = set(range(10000)) b = set(range(10000))
main()' > test.py main()' > test.py
$ kernprof -lv test.py $ kernprof -lv test.py
Line # Hits Time Per Hit % Time Line Contents Line # Hits Time Per Hit % Time Line Contents
======================================================= ==============================================================
1 @profile 1 @profile
2 def main(): 2 def main():
3 1 219.0 219.0 31.1 a = list(range(10000)) 3 1 253.4 253.4 32.2 a = list(range(10000))
4 1 487.0 487.0 68.9 b = set(range(10000)) 4 1 534.1 534.1 67.8 b = set(range(10000))
``` ```
### Call and Flame Graphs ### Call and Flame Graphs
@ -2624,15 +2624,14 @@ $ snakeviz test.prof
### Sampling and Memory Profilers ### Sampling and Memory Profilers
```text ```text
+--------------+-------------------------------+------------+----------+------+ +--------------+----------+------------+-------------------------------+------+
| pip3 install | How to run | Target | Type | Live | | pip3 install | Type | Target | How to run | Live |
+--------------+-------------------------------+------------+----------+------+ +--------------+----------+------------+-------------------------------+------+
| py-spy | py-spy top -- python3 test.py | CPU | Sampling | Yes | | pyinstrument | Sampling | CPU | pyinstrument test.py | No |
| pyinstrument | pyinstrument test.py | CPU | Sampling | No | | py-spy | Sampling | CPU | py-spy top -- python3 test.py | Yes |
| scalene | scalene test.py | CPU+Memory | Sampling | No | | scalene | Sampling | CPU+Memory | scalene test.py | No |
| memray | memray run --live test.py | Memory | Tracing | Yes | | memray | Tracing | Memory | memray run --live test.py | Yes |
| filprofiler | fil-profile run test.py | Memory | Tracing | No | +--------------+----------+------------+-------------------------------+------+
+--------------+-------------------------------+------------+----------+------+
``` ```

33
index.html

@ -54,7 +54,7 @@
<body> <body>
<header> <header>
<aside>November 19, 2023</aside> <aside>November 29, 2023</aside>
<a href="https://gto76.github.io" rel="author">Jure Šorn</a> <a href="https://gto76.github.io" rel="author">Jure Šorn</a>
</header> </header>
@ -2130,12 +2130,12 @@ def main():
b = set(range(10000)) b = set(range(10000))
main()' &gt; test.py main()' &gt; test.py
$ kernprof -lv test.py $ kernprof -lv test.py
Line # Hits Time Per Hit % Time Line Contents Line # Hits Time Per Hit % Time Line Contents
======================================================= ==============================================================
1 @profile 1 @profile
2 def main(): 2 def main():
3 1 219.0 219.0 31.1 a = list(range(10000)) 3 1 253.4 253.4 32.2 a = list(range(10000))
4 1 487.0 487.0 68.9 b = set(range(10000)) 4 1 534.1 534.1 67.8 b = set(range(10000))
</code></pre></div> </code></pre></div>
<div><h3 id="callandflamegraphs">Call and Flame Graphs</h3><pre><code class="text language-text">$ pip3 install gprof2dot snakeviz; apt/brew install graphviz <div><h3 id="callandflamegraphs">Call and Flame Graphs</h3><pre><code class="text language-text">$ pip3 install gprof2dot snakeviz; apt/brew install graphviz
@ -2145,15 +2145,14 @@ $ gprof2dot -f pstats test.prof | dot -T png -o test.png; xdg-open/open test.png
$ snakeviz test.prof $ snakeviz test.prof
</code></pre></div> </code></pre></div>
<div><h3 id="samplingandmemoryprofilers">Sampling and Memory Profilers</h3><pre><code class="text language-text">┏━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━┯━━━━━━━━━━┯━━━━━━┓ <div><h3 id="samplingandmemoryprofilers">Sampling and Memory Profilers</h3><pre><code class="text language-text">┏━━━━━━━━━━━━━━┯━━━━━━━━━━┯━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┯━━━━━━┓
┃ pip3 install │ How to run │ Target │ Type │ Live ┃ ┃ pip3 install │ Type │ Target │ How to run │ Live ┃
┠──────────────┼───────────────────────────────┼────────────┼──────────┼──────┨ ┠──────────────┼──────────┼────────────┼───────────────────────────────┼──────┨
┃ py-spy │ py-spy top -- python3 test.py │ CPU │ Sampling │ Yes ┃ ┃ pyinstrument │ Sampling │ CPU │ pyinstrument test.py │ × ┃
┃ pyinstrument │ pyinstrument test.py │ CPU │ Sampling │ No ┃ ┃ py-spy │ Sampling │ CPU │ py-spy top -- python3 test.py │ ✓ ┃
┃ scalene │ scalene test.py │ CPU+Memory │ Sampling │ No ┃ ┃ scalene │ Sampling │ CPU+Memory │ scalene test.py │ × ┃
┃ memray │ memray run --live test.py │ Memory │ Tracing │ Yes ┃ ┃ memray │ Tracing │ Memory │ memray run --live test.py │ ✓ ┃
┃ filprofiler │ fil-profile run test.py │ Memory │ Tracing │ No ┃ ┗━━━━━━━━━━━━━━┷━━━━━━━━━━┷━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┷━━━━━━┛
┗━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━┷━━━━━━━━━━┷━━━━━━┛
</code></pre></div> </code></pre></div>
<div><h2 id="numpy"><a href="#numpy" name="numpy">#</a>NumPy</h2><p><strong>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.</strong></p><pre><code class="python language-python hljs"><span class="hljs-comment"># $ pip3 install numpy</span> <div><h2 id="numpy"><a href="#numpy" name="numpy">#</a>NumPy</h2><p><strong>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.</strong></p><pre><code class="python language-python hljs"><span class="hljs-comment"># $ pip3 install numpy</span>
@ -2926,7 +2925,7 @@ $ deactivate <span class="hljs-comment"># Deactivates the activ
<footer> <footer>
<aside>November 19, 2023</aside> <aside>November 29, 2023</aside>
<a href="https://gto76.github.io" rel="author">Jure Šorn</a> <a href="https://gto76.github.io" rel="author">Jure Šorn</a>
</footer> </footer>

23
parse.js

@ -517,20 +517,19 @@ const DIAGRAM_11_B =
'┗━━━━━━━━━━━━━┷━━━━━━━━━━━━━┛\n'; '┗━━━━━━━━━━━━━┷━━━━━━━━━━━━━┛\n';
const DIAGRAM_115_A = const DIAGRAM_115_A =
'+--------------+-------------------------------+------------+----------+------+\n' + '+--------------+----------+------------+-------------------------------+------+\n' +
'| pip3 install | How to run | Target | Type | Live |\n' + '| pip3 install | Type | Target | How to run | Live |\n' +
'+--------------+-------------------------------+------------+----------+------+\n'; '+--------------+----------+------------+-------------------------------+------+\n';
const DIAGRAM_115_B = const DIAGRAM_115_B =
'┏━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━┯━━━━━━━━━━┯━━━━━━┓\n' + '┏━━━━━━━━━━━━━━┯━━━━━━━━━━┯━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┯━━━━━━┓\n' +
'┃ pip3 install │ How to run │ Target │ Type │ Live ┃\n' + '┃ pip3 install │ Type │ Target │ How to run │ Live ┃\n' +
'┠──────────────┼───────────────────────────────┼────────────┼──────────┼──────┨\n' + '┠──────────────┼──────────┼────────────┼───────────────────────────────┼──────┨\n' +
'┃ py-spy │ py-spy top -- python3 test.py │ CPU │ Sampling │ Yes ┃\n' + '┃ pyinstrument │ Sampling │ CPU │ pyinstrument test.py │ × ┃\n' +
'┃ pyinstrument │ pyinstrument test.py │ CPU │ Sampling │ No ┃\n' + '┃ py-spy │ Sampling │ CPU │ py-spy top -- python3 test.py │ ✓ ┃\n' +
'┃ scalene │ scalene test.py │ CPU+Memory │ Sampling │ No ┃\n' + '┃ scalene │ Sampling │ CPU+Memory │ scalene test.py │ × ┃\n' +
'┃ memray │ memray run --live test.py │ Memory │ Tracing │ Yes ┃\n' + '┃ memray │ Tracing │ Memory │ memray run --live test.py │ ✓ ┃\n' +
'┃ filprofiler │ fil-profile run test.py │ Memory │ Tracing │ No ┃\n' + '┗━━━━━━━━━━━━━━┷━━━━━━━━━━┷━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┷━━━━━━┛\n';
'┗━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━┷━━━━━━━━━━┷━━━━━━┛\n';
const DIAGRAM_12_A = const DIAGRAM_12_A =
'+-----------+-----------+------+-----------+\n' + '+-----------+-----------+------+-----------+\n' +

|||||||
100:0
Loading…
Cancel
Save