Browse Source

Profiling

pull/170/head
Jure Šorn 11 months 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))
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 |
+--------------+----------+------------+-------------------------------+------+
```

33
index.html

@ -54,7 +54,7 @@
<body>
<header>
<aside>November 19, 2023</aside>
<aside>November 29, 2023</aside>
<a href="https://gto76.github.io" rel="author">Jure Šorn</a>
</header>
@ -2130,12 +2130,12 @@ def main():
b = set(range(10000))
main()' &gt; 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))
</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
@ -2145,15 +2145,14 @@ $ gprof2dot -f pstats test.prof | dot -T png -o test.png; xdg-open/open test.png
$ snakeviz test.prof
</code></pre></div>
<div><h3 id="samplingandmemoryprofilers">Sampling and Memory Profilers</h3><pre><code class="text language-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 ┃
┗━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━┷━━━━━━━━━━┷━━━━━━┛
<div><h3 id="samplingandmemoryprofilers">Sampling and Memory Profilers</h3><pre><code class="text language-text">┏━━━━━━━━━━━━━━┯━━━━━━━━━━┯━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┯━━━━━━┓
┃ 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 │ ✓ ┃
┗━━━━━━━━━━━━━━┷━━━━━━━━━━┷━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┷━━━━━━┛
</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>
@ -2926,7 +2925,7 @@ $ deactivate <span class="hljs-comment"># Deactivates the activ
<footer>
<aside>November 19, 2023</aside>
<aside>November 29, 2023</aside>
<a href="https://gto76.github.io" rel="author">Jure Šorn</a>
</footer>

23
parse.js

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

Loading…
Cancel
Save