| 1 |
{ |
| 2 |
"cells": [ |
| 3 |
{ |
| 4 |
"cell_type": "code", |
| 5 |
"execution_count": 1, |
| 6 |
"id": "verbal-arrival", |
| 7 |
"metadata": {}, |
| 8 |
"outputs": [], |
| 9 |
"source": [ |
| 10 |
"# An example program to profile\n", |
| 11 |
"\n", |
| 12 |
"import numpy as np\n", |
| 13 |
"\n", |
| 14 |
"def test_me():\n", |
| 15 |
" for i in range(6):\n", |
| 16 |
" x = np.array(range(10**7))\n", |
| 17 |
" y = np.array(np.random.uniform(0, 100, size=(10**8)))\n" |
| 18 |
] |
| 19 |
}, |
| 20 |
{ |
| 21 |
"cell_type": "code", |
| 22 |
"execution_count": 2, |
| 23 |
"id": "lesbian-premium", |
| 24 |
"metadata": {}, |
| 25 |
"outputs": [ |
| 26 |
{ |
| 27 |
"name": "stdout", |
| 28 |
"output_type": "stream", |
| 29 |
"text": [ |
| 30 |
"The scalene extension is already loaded. To reload it, use:\n", |
| 31 |
" %reload_ext scalene\n" |
| 32 |
] |
| 33 |
} |
| 34 |
], |
| 35 |
"source": [ |
| 36 |
"# Load Scalene\n", |
| 37 |
"%load_ext scalene" |
| 38 |
] |
| 39 |
}, |
| 40 |
{ |
| 41 |
"cell_type": "code", |
| 42 |
"execution_count": 3, |
| 43 |
"id": "listed-keyboard", |
| 44 |
"metadata": {}, |
| 45 |
"outputs": [ |
| 46 |
{ |
| 47 |
"data": { |
| 48 |
"text/html": [ |
| 49 |
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"font-style: italic\"> [1]: % of time = 100.00% out of 6.02s. </span>\n", |
| 50 |
" ╷ ╷ ╷ ╷ \n", |
| 51 |
" <span style=\"font-weight: bold\"> Line </span>│<span style=\"font-weight: bold\">Time </span>│<span style=\"font-weight: bold\">–––––– </span>│<span style=\"font-weight: bold\">–––––– </span>│<span style=\"font-weight: bold\"> </span> \n", |
| 52 |
" │<span style=\"font-weight: bold; font-style: italic\">Python</span><span style=\"font-weight: bold\"> </span>│<span style=\"font-weight: bold; font-style: italic\">native</span><span style=\"font-weight: bold\"> </span>│<span style=\"font-weight: bold; font-style: italic\">system</span><span style=\"font-weight: bold\"> </span>│<span style=\"font-weight: bold\">[1] </span> \n", |
| 53 |
"╺━━━━━━━┿━━━━━━━━┿━━━━━━━┿━━━━━━━┿━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╸\n", |
| 54 |
" <span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\"> 1 </span>│ │ │ │<span style=\"color: #000080; text-decoration-color: #000080; background-color: #000000\"># An example program to profile</span><span style=\"background-color: #000000\"> </span> \n", |
| 55 |
" <span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\"> 2 </span>│ │ │ │<span style=\"background-color: #000000\"> </span> \n", |
| 56 |
" <span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\"> 3 </span>│ │ │ │<span style=\"color: #cd00cd; text-decoration-color: #cd00cd; background-color: #000000\">import</span><span style=\"color: #cccccc; text-decoration-color: #cccccc; background-color: #000000\"> numpy </span><span style=\"color: #cdcd00; text-decoration-color: #cdcd00; background-color: #000000\">as</span><span style=\"color: #cccccc; text-decoration-color: #cccccc; background-color: #000000\"> np</span><span style=\"background-color: #000000\"> </span> \n", |
| 57 |
" <span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\"> 4 </span>│ │ │ │<span style=\"background-color: #000000\"> </span> \n", |
| 58 |
" <span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\"> 5 </span>│ │ │ │<span style=\"color: #cdcd00; text-decoration-color: #cdcd00; background-color: #000000\">def</span><span style=\"color: #cccccc; text-decoration-color: #cccccc; background-color: #000000\"> test_me():</span><span style=\"background-color: #000000\"> </span> \n", |
| 59 |
" <span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\"> 6 </span>│ │ │ │<span style=\"color: #cccccc; text-decoration-color: #cccccc; background-color: #000000\"> </span><span style=\"color: #cdcd00; text-decoration-color: #cdcd00; background-color: #000000\">for</span><span style=\"color: #cccccc; text-decoration-color: #cccccc; background-color: #000000\"> i </span><span style=\"color: #cdcd00; text-decoration-color: #cdcd00; background-color: #000000\">in</span><span style=\"color: #cccccc; text-decoration-color: #cccccc; background-color: #000000\"> </span><span style=\"color: #cd00cd; text-decoration-color: #cd00cd; background-color: #000000\">range</span><span style=\"color: #cccccc; text-decoration-color: #cccccc; background-color: #000000\">(</span><span style=\"color: #cd00cd; text-decoration-color: #cd00cd; background-color: #000000\">6</span><span style=\"color: #cccccc; text-decoration-color: #cccccc; background-color: #000000\">):</span><span style=\"background-color: #000000\"> </span> \n", |
| 60 |
" <span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\"> 7 </span>│<span style=\"color: #800000; text-decoration-color: #800000; font-weight: bold\"> 1%</span> │<span style=\"color: #800000; text-decoration-color: #800000; font-weight: bold\"> 35%</span> │ 7% │<span style=\"color: #cccccc; text-decoration-color: #cccccc; background-color: #000000\"> x </span><span style=\"color: #3399cc; text-decoration-color: #3399cc; background-color: #000000\">=</span><span style=\"color: #cccccc; text-decoration-color: #cccccc; background-color: #000000\"> np</span><span style=\"color: #3399cc; text-decoration-color: #3399cc; background-color: #000000\">.</span><span style=\"color: #cccccc; text-decoration-color: #cccccc; background-color: #000000\">array(</span><span style=\"color: #cd00cd; text-decoration-color: #cd00cd; background-color: #000000\">range</span><span style=\"color: #cccccc; text-decoration-color: #cccccc; background-color: #000000\">(</span><span style=\"color: #cd00cd; text-decoration-color: #cd00cd; background-color: #000000\">10</span><span style=\"color: #3399cc; text-decoration-color: #3399cc; background-color: #000000\">**</span><span style=\"color: #cd00cd; text-decoration-color: #cd00cd; background-color: #000000\">7</span><span style=\"color: #cccccc; text-decoration-color: #cccccc; background-color: #000000\">))</span><span style=\"background-color: #000000\"> </span> \n", |
| 61 |
" <span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\"> 8 </span>│<span style=\"color: #800000; text-decoration-color: #800000; font-weight: bold\"> 2%</span> │<span style=\"color: #800000; text-decoration-color: #800000; font-weight: bold\"> 55%</span> │ │<span style=\"color: #cccccc; text-decoration-color: #cccccc; background-color: #000000\"> y </span><span style=\"color: #3399cc; text-decoration-color: #3399cc; background-color: #000000\">=</span><span style=\"color: #cccccc; text-decoration-color: #cccccc; background-color: #000000\"> np</span><span style=\"color: #3399cc; text-decoration-color: #3399cc; background-color: #000000\">.</span><span style=\"color: #cccccc; text-decoration-color: #cccccc; background-color: #000000\">array(np</span><span style=\"color: #3399cc; text-decoration-color: #3399cc; background-color: #000000\">.</span><span style=\"color: #cccccc; text-decoration-color: #cccccc; background-color: #000000\">random</span><span style=\"color: #3399cc; text-decoration-color: #3399cc; background-color: #000000\">.</span><span style=\"color: #cccccc; text-decoration-color: #cccccc; background-color: #000000\">uniform(</span><span style=\"color: #cd00cd; text-decoration-color: #cd00cd; background-color: #000000\">0</span><span style=\"color: #cccccc; text-decoration-color: #cccccc; background-color: #000000\">, </span><span style=\"color: #cd00cd; text-decoration-color: #cd00cd; background-color: #000000\">100</span><span style=\"color: #cccccc; text-decoration-color: #cccccc; background-color: #000000\">, size</span><span style=\"color: #3399cc; text-decoration-color: #3399cc; background-color: #000000\">=</span><span style=\"color: #cccccc; text-decoration-color: #cccccc; background-color: #000000\">(</span><span style=\"color: #cd00cd; text-decoration-color: #cd00cd; background-color: #000000\">10</span><span style=\"color: #3399cc; text-decoration-color: #3399cc; background-color: #000000\">**</span><span style=\"color: #cd00cd; text-decoration-color: #cd00cd; background-color: #000000\">8</span><span style=\"color: #cccccc; text-decoration-color: #cccccc; background-color: #000000\">)))</span><span style=\"background-color: #000000\"> </span> \n", |
| 62 |
" <span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\"> </span>│ │ │ │ \n", |
| 63 |
"╶───────┼────────┼───────┼───────┼────────────────────────────────────────────────────────────────────────────────────────────────╴\n", |
| 64 |
" <span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\"> </span>│ │ │ │<span style=\"font-weight: bold; font-style: italic\">function summary for <ipython-input-14-3a53cdc5d2d5> </span> \n", |
| 65 |
" <span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\"> 5 </span>│<span style=\"color: #800000; text-decoration-color: #800000; font-weight: bold\"> 3%</span> │<span style=\"color: #800000; text-decoration-color: #800000; font-weight: bold\"> 91%</span> │ 6% │<span style=\"color: #cccccc; text-decoration-color: #cccccc; background-color: #000000\">test_me</span><span style=\"background-color: #000000\"> </span> \n", |
| 66 |
" ╵ ╵ ╵ ╵ \n", |
| 67 |
"</pre>\n" |
| 68 |
], |
| 69 |
"text/plain": [ |
| 70 |
"<rich.jupyter.JupyterRenderable at 0x1050b0d60>" |
| 71 |
] |
| 72 |
}, |
| 73 |
"metadata": {}, |
| 74 |
"output_type": "display_data" |
| 75 |
} |
| 76 |
], |
| 77 |
"source": [ |
| 78 |
"# Profile just one line of code\n", |
| 79 |
"%scrun test_me()" |
| 80 |
] |
| 81 |
}, |
| 82 |
{ |
| 83 |
"cell_type": "code", |
| 84 |
"execution_count": 4, |
| 85 |
"id": "digital-ratio", |
| 86 |
"metadata": {}, |
| 87 |
"outputs": [ |
| 88 |
{ |
| 89 |
"name": "stdout", |
| 90 |
"output_type": "stream", |
| 91 |
"text": [ |
| 92 |
"usage: scalene [-h] [--version] [--outfile OUTFILE] [--html]\n", |
| 93 |
" [--reduced-profile] [--profile-interval PROFILE_INTERVAL]\n", |
| 94 |
" [--cpu-only] [--profile-all] [--profile-only PROFILE_ONLY]\n", |
| 95 |
" [--use-virtual-time]\n", |
| 96 |
" [--cpu-percent-threshold CPU_PERCENT_THRESHOLD]\n", |
| 97 |
" [--cpu-sampling-rate CPU_SAMPLING_RATE]\n", |
| 98 |
" [--malloc-threshold MALLOC_THRESHOLD]\n", |
| 99 |
"\n", |
| 100 |
"Scalene: a high-precision CPU and memory profiler, version 1.3.2\n", |
| 101 |
"https://github.com/plasma-umass/scalene\n", |
| 102 |
"\n", |
| 103 |
"command-line:\n", |
| 104 |
" % scalene [options] yourprogram.py\n", |
| 105 |
"or\n", |
| 106 |
" % python3 -m scalene [options] yourprogram.py\n", |
| 107 |
"\n", |
| 108 |
"in Jupyter, line mode:\n", |
| 109 |
" %scrun [options] statement\n", |
| 110 |
"\n", |
| 111 |
"in Jupyter, cell mode:\n", |
| 112 |
" %%scalene [options]\n", |
| 113 |
" code...\n", |
| 114 |
" code...\n", |
| 115 |
"\n", |
| 116 |
"optional arguments:\n", |
| 117 |
" -h, --help show this help message and exit\n", |
| 118 |
" --version prints the version number for this release of Scalene and exits\n", |
| 119 |
" --outfile OUTFILE file to hold profiler output (default: stdout)\n", |
| 120 |
" --html output as HTML (default: text)\n", |
| 121 |
" --reduced-profile generate a reduced profile, with non-zero lines only (default: False)\n", |
| 122 |
" --profile-interval PROFILE_INTERVAL\n", |
| 123 |
" output profiles every so many seconds (default: inf)\n", |
| 124 |
" --cpu-only only profile CPU time (default: profile CPU, memory, and copying)\n", |
| 125 |
" --profile-all profile all executed code, not just the target program (default: only the target program)\n", |
| 126 |
" --profile-only PROFILE_ONLY\n", |
| 127 |
" profile only code in files matching the given strings, separated by commas (default: no restrictions)\n", |
| 128 |
" --use-virtual-time measure only CPU time, not time spent in I/O or blocking (default: False)\n", |
| 129 |
" --cpu-percent-threshold CPU_PERCENT_THRESHOLD\n", |
| 130 |
" only report profiles with at least this percent of CPU time (default: 1%)\n", |
| 131 |
" --cpu-sampling-rate CPU_SAMPLING_RATE\n", |
| 132 |
" CPU sampling rate (default: every 0.01s)\n", |
| 133 |
" --malloc-threshold MALLOC_THRESHOLD\n", |
| 134 |
" only report profiles with at least this many allocations (default: 100)\n", |
| 135 |
"\n", |
| 136 |
"When running Scalene in the background, you can suspend/resume profiling\n", |
| 137 |
"for the process ID that Scalene reports. For example:\n", |
| 138 |
"\n", |
| 139 |
" % python3 -m scalene [options] yourprogram.py &\n", |
| 140 |
" Scalene now profiling process 12345\n", |
| 141 |
" to suspend profiling: python3 -m scalene.profile --off --pid 12345\n", |
| 142 |
" to resume profiling: python3 -m scalene.profile --on --pid 12345\n" |
| 143 |
] |
| 144 |
} |
| 145 |
], |
| 146 |
"source": [ |
| 147 |
"# A full list of options\n", |
| 148 |
"%scrun --help" |
| 149 |
] |
| 150 |
}, |
| 151 |
{ |
| 152 |
"cell_type": "code", |
| 153 |
"execution_count": 5, |
| 154 |
"id": "radio-feelings", |
| 155 |
"metadata": {}, |
| 156 |
"outputs": [ |
| 157 |
{ |
| 158 |
"data": { |
| 159 |
"text/html": [ |
| 160 |
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"font-style: italic\"> [1]: % of time = 100.00% out of 6.67s. </span>\n", |
| 161 |
" ╷ ╷ ╷ ╷ \n", |
| 162 |
" <span style=\"font-weight: bold\"> Line </span>│<span style=\"font-weight: bold\">Time </span>│<span style=\"font-weight: bold\">–––––– </span>│<span style=\"font-weight: bold\">–––––– </span>│<span style=\"font-weight: bold\"> </span> \n", |
| 163 |
" │<span style=\"font-weight: bold; font-style: italic\">Python</span><span style=\"font-weight: bold\"> </span>│<span style=\"font-weight: bold; font-style: italic\">native</span><span style=\"font-weight: bold\"> </span>│<span style=\"font-weight: bold; font-style: italic\">system</span><span style=\"font-weight: bold\"> </span>│<span style=\"font-weight: bold\">[1] </span> \n", |
| 164 |
"╺━━━━━━━┿━━━━━━━━┿━━━━━━━┿━━━━━━━┿━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╸\n", |
| 165 |
" <span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\"> ... </span>│ │ │ │ \n", |
| 166 |
" <span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\"> 7 </span>│ │<span style=\"color: #800000; text-decoration-color: #800000; font-weight: bold\"> 34%</span> │ 7% │<span style=\"color: #cccccc; text-decoration-color: #cccccc; background-color: #000000\"> x </span><span style=\"color: #3399cc; text-decoration-color: #3399cc; background-color: #000000\">=</span><span style=\"color: #cccccc; text-decoration-color: #cccccc; background-color: #000000\"> np</span><span style=\"color: #3399cc; text-decoration-color: #3399cc; background-color: #000000\">.</span><span style=\"color: #cccccc; text-decoration-color: #cccccc; background-color: #000000\">array(</span><span style=\"color: #cd00cd; text-decoration-color: #cd00cd; background-color: #000000\">range</span><span style=\"color: #cccccc; text-decoration-color: #cccccc; background-color: #000000\">(</span><span style=\"color: #cd00cd; text-decoration-color: #cd00cd; background-color: #000000\">10</span><span style=\"color: #3399cc; text-decoration-color: #3399cc; background-color: #000000\">**</span><span style=\"color: #cd00cd; text-decoration-color: #cd00cd; background-color: #000000\">7</span><span style=\"color: #cccccc; text-decoration-color: #cccccc; background-color: #000000\">))</span><span style=\"background-color: #000000\"> </span> \n", |
| 167 |
" <span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\"> 8 </span>│<span style=\"color: #800000; text-decoration-color: #800000; font-weight: bold\"> 2%</span> │<span style=\"color: #800000; text-decoration-color: #800000; font-weight: bold\"> 49%</span> │ 8% │<span style=\"color: #cccccc; text-decoration-color: #cccccc; background-color: #000000\"> y </span><span style=\"color: #3399cc; text-decoration-color: #3399cc; background-color: #000000\">=</span><span style=\"color: #cccccc; text-decoration-color: #cccccc; background-color: #000000\"> np</span><span style=\"color: #3399cc; text-decoration-color: #3399cc; background-color: #000000\">.</span><span style=\"color: #cccccc; text-decoration-color: #cccccc; background-color: #000000\">array(np</span><span style=\"color: #3399cc; text-decoration-color: #3399cc; background-color: #000000\">.</span><span style=\"color: #cccccc; text-decoration-color: #cccccc; background-color: #000000\">random</span><span style=\"color: #3399cc; text-decoration-color: #3399cc; background-color: #000000\">.</span><span style=\"color: #cccccc; text-decoration-color: #cccccc; background-color: #000000\">uniform(</span><span style=\"color: #cd00cd; text-decoration-color: #cd00cd; background-color: #000000\">0</span><span style=\"color: #cccccc; text-decoration-color: #cccccc; background-color: #000000\">, </span><span style=\"color: #cd00cd; text-decoration-color: #cd00cd; background-color: #000000\">100</span><span style=\"color: #cccccc; text-decoration-color: #cccccc; background-color: #000000\">, size</span><span style=\"color: #3399cc; text-decoration-color: #3399cc; background-color: #000000\">=</span><span style=\"color: #cccccc; text-decoration-color: #cccccc; background-color: #000000\">(</span><span style=\"color: #cd00cd; text-decoration-color: #cd00cd; background-color: #000000\">10</span><span style=\"color: #3399cc; text-decoration-color: #3399cc; background-color: #000000\">**</span><span style=\"color: #cd00cd; text-decoration-color: #cd00cd; background-color: #000000\">8</span><span style=\"color: #cccccc; text-decoration-color: #cccccc; background-color: #000000\">)))</span><span style=\"background-color: #000000\"> </span> \n", |
| 168 |
" <span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\"> </span>│ │ │ │ \n", |
| 169 |
"╶───────┼────────┼───────┼───────┼────────────────────────────────────────────────────────────────────────────────────────────────╴\n", |
| 170 |
" <span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\"> </span>│ │ │ │<span style=\"font-weight: bold; font-style: italic\">function summary for <ipython-input-14-3a53cdc5d2d5> </span> \n", |
| 171 |
" <span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\"> 5 </span>│<span style=\"color: #800000; text-decoration-color: #800000; font-weight: bold\"> 2%</span> │<span style=\"color: #800000; text-decoration-color: #800000; font-weight: bold\"> 83%</span> │ 15% │<span style=\"color: #cccccc; text-decoration-color: #cccccc; background-color: #000000\">test_me</span><span style=\"background-color: #000000\"> </span> \n", |
| 172 |
" ╵ ╵ ╵ ╵ \n", |
| 173 |
"</pre>\n" |
| 174 |
], |
| 175 |
"text/plain": [ |
| 176 |
"<rich.jupyter.JupyterRenderable at 0x105073220>" |
| 177 |
] |
| 178 |
}, |
| 179 |
"metadata": {}, |
| 180 |
"output_type": "display_data" |
| 181 |
} |
| 182 |
], |
| 183 |
"source": [ |
| 184 |
"# Generate a reduced profile (only lines with non-zero counts)\n", |
| 185 |
"%scrun --reduced-profile test_me()" |
| 186 |
] |
| 187 |
}, |
| 188 |
{ |
| 189 |
"cell_type": "code", |
| 190 |
"execution_count": 6, |
| 191 |
"id": "minimal-society", |
| 192 |
"metadata": {}, |
| 193 |
"outputs": [ |
| 194 |
{ |
| 195 |
"data": { |
| 196 |
"text/html": [ |
| 197 |
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"font-style: italic\"> /var/folders/m7/sln1lr497jqcchb2ddh32rw00000gq/T/scalene_profile_qxy9xnh3.py: % of time = 100.00% out of 0.09s. </span>\n", |
| 198 |
" ╷ ╷ ╷ ╷ \n", |
| 199 |
" <span style=\"font-weight: bold\"> Line </span>│<span style=\"font-weight: bold\">Time </span>│<span style=\"font-weight: bold\">–––––– </span>│<span style=\"font-weight: bold\">–––––– </span>│<span style=\"font-weight: bold\"> </span> \n", |
| 200 |
" │<span style=\"font-weight: bold; font-style: italic\">Python</span><span style=\"font-weight: bold\"> </span>│<span style=\"font-weight: bold; font-style: italic\">native</span><span style=\"font-weight: bold\"> </span>│<span style=\"font-weight: bold; font-style: italic\">system</span><span style=\"font-weight: bold\"> </span>│<span style=\"font-weight: bold\">/var/folders/m7/sln1lr497jqcchb2ddh32rw00000gq/T/scalene_profile_qxy9xnh3.py </span> \n", |
| 201 |
"╺━━━━━━━┿━━━━━━━━┿━━━━━━━┿━━━━━━━┿━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╸\n", |
| 202 |
" <span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\"> ... </span>│ │ │ │ \n", |
| 203 |
" <span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\"> 4 </span>│ 21% │ │ │<span style=\"color: #cccccc; text-decoration-color: #cccccc; background-color: #000000\"> </span><span style=\"color: #cdcd00; text-decoration-color: #cdcd00; background-color: #000000\">for</span><span style=\"color: #cccccc; text-decoration-color: #cccccc; background-color: #000000\"> j </span><span style=\"color: #cdcd00; text-decoration-color: #cdcd00; background-color: #000000\">in</span><span style=\"color: #cccccc; text-decoration-color: #cccccc; background-color: #000000\"> </span><span style=\"color: #cd00cd; text-decoration-color: #cd00cd; background-color: #000000\">range</span><span style=\"color: #cccccc; text-decoration-color: #cccccc; background-color: #000000\">(</span><span style=\"color: #cd00cd; text-decoration-color: #cd00cd; background-color: #000000\">1000</span><span style=\"color: #cccccc; text-decoration-color: #cccccc; background-color: #000000\">):</span><span style=\"background-color: #000000\"> </span> \n", |
| 204 |
" <span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\"> 5 </span>│<span style=\"color: #800000; text-decoration-color: #800000; font-weight: bold\"> 59%</span> │<span style=\"color: #800000; text-decoration-color: #800000; font-weight: bold\"> 6%</span> │ 13% │<span style=\"color: #cccccc; text-decoration-color: #cccccc; background-color: #000000\"> x </span><span style=\"color: #3399cc; text-decoration-color: #3399cc; background-color: #000000\">+=</span><span style=\"color: #cccccc; text-decoration-color: #cccccc; background-color: #000000\"> </span><span style=\"color: #cd00cd; text-decoration-color: #cd00cd; background-color: #000000\">1</span><span style=\"background-color: #000000\"> </span> \n", |
| 205 |
" ╵ ╵ ╵ ╵ \n", |
| 206 |
"</pre>\n" |
| 207 |
], |
| 208 |
"text/plain": [ |
| 209 |
"<rich.jupyter.JupyterRenderable at 0x10743c640>" |
| 210 |
] |
| 211 |
}, |
| 212 |
"metadata": {}, |
| 213 |
"output_type": "display_data" |
| 214 |
} |
| 215 |
], |
| 216 |
"source": [ |
| 217 |
"%%scalene --reduced-profile\n", |
| 218 |
"# Profile more than one line of code in a cell\n", |
| 219 |
"x = 0\n", |
| 220 |
"for i in range(1000):\n", |
| 221 |
" for j in range(1000):\n", |
| 222 |
" x += 1" |
| 223 |
] |
| 224 |
}, |
| 225 |
{ |
| 226 |
"cell_type": "code", |
| 227 |
"execution_count": null, |
| 228 |
"id": "hungry-yesterday", |
| 229 |
"metadata": {}, |
| 230 |
"outputs": [], |
| 231 |
"source": [] |
| 232 |
} |
| 233 |
], |
| 234 |
"metadata": { |
| 235 |
"kernelspec": { |
| 236 |
"display_name": "Python 3", |
| 237 |
"language": "python", |
| 238 |
"name": "python3" |
| 239 |
}, |
| 240 |
"language_info": { |
| 241 |
"codemirror_mode": { |
| 242 |
"name": "ipython", |
| 243 |
"version": 3 |
| 244 |
}, |
| 245 |
"file_extension": ".py", |
| 246 |
"mimetype": "text/x-python", |
| 247 |
"name": "python", |
| 248 |
"nbconvert_exporter": "python", |
| 249 |
"pygments_lexer": "ipython3", |
| 250 |
"version": "3.9.2" |
| 251 |
} |
| 252 |
}, |
| 253 |
"nbformat": 4, |
| 254 |
"nbformat_minor": 5 |
| 255 |
} |