{ "cells": [ { "cell_type": "code", "execution_count": 1, "id": "verbal-arrival", "metadata": {}, "outputs": [], "source": [ "# An example program to profile\n", "\n", "import numpy as np\n", "\n", "def test_me():\n", " for i in range(6):\n", " x = np.array(range(10**7))\n", " y = np.array(np.random.uniform(0, 100, size=(10**8)))\n" ] }, { "cell_type": "code", "execution_count": 2, "id": "lesbian-premium", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "The scalene extension is already loaded. To reload it, use:\n", " %reload_ext scalene\n" ] } ], "source": [ "# Load Scalene\n", "%load_ext scalene" ] }, { "cell_type": "code", "execution_count": 3, "id": "listed-keyboard", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
[1]: % of time = 100.00% out of 6.02s. \n", " ╷ ╷ ╷ ╷ \n", " Line │Time │–––––– │–––––– │ \n", " │Python │native │system │[1] \n", "╺━━━━━━━┿━━━━━━━━┿━━━━━━━┿━━━━━━━┿━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╸\n", " 1 │ │ │ │# An example program to profile \n", " 2 │ │ │ │ \n", " 3 │ │ │ │import numpy as np \n", " 4 │ │ │ │ \n", " 5 │ │ │ │def test_me(): \n", " 6 │ │ │ │ for i in range(6): \n", " 7 │ 1% │ 35% │ 7% │ x = np.array(range(10**7)) \n", " 8 │ 2% │ 55% │ │ y = np.array(np.random.uniform(0, 100, size=(10**8))) \n", " │ │ │ │ \n", "╶───────┼────────┼───────┼───────┼────────────────────────────────────────────────────────────────────────────────────────────────╴\n", " │ │ │ │function summary for <ipython-input-14-3a53cdc5d2d5> \n", " 5 │ 3% │ 91% │ 6% │test_me \n", " ╵ ╵ ╵ ╵ \n", "\n" ], "text/plain": [ "
[1]: % of time = 100.00% out of 6.67s. \n", " ╷ ╷ ╷ ╷ \n", " Line │Time │–––––– │–––––– │ \n", " │Python │native │system │[1] \n", "╺━━━━━━━┿━━━━━━━━┿━━━━━━━┿━━━━━━━┿━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╸\n", " ... │ │ │ │ \n", " 7 │ │ 34% │ 7% │ x = np.array(range(10**7)) \n", " 8 │ 2% │ 49% │ 8% │ y = np.array(np.random.uniform(0, 100, size=(10**8))) \n", " │ │ │ │ \n", "╶───────┼────────┼───────┼───────┼────────────────────────────────────────────────────────────────────────────────────────────────╴\n", " │ │ │ │function summary for <ipython-input-14-3a53cdc5d2d5> \n", " 5 │ 2% │ 83% │ 15% │test_me \n", " ╵ ╵ ╵ ╵ \n", "\n" ], "text/plain": [ "
/var/folders/m7/sln1lr497jqcchb2ddh32rw00000gq/T/scalene_profile_qxy9xnh3.py: % of time = 100.00% out of 0.09s. \n", " ╷ ╷ ╷ ╷ \n", " Line │Time │–––––– │–––––– │ \n", " │Python │native │system │/var/folders/m7/sln1lr497jqcchb2ddh32rw00000gq/T/scalene_profile_qxy9xnh3.py \n", "╺━━━━━━━┿━━━━━━━━┿━━━━━━━┿━━━━━━━┿━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╸\n", " ... │ │ │ │ \n", " 4 │ 21% │ │ │ for j in range(1000): \n", " 5 │ 59% │ 6% │ 13% │ x += 1 \n", " ╵ ╵ ╵ ╵ \n", "\n" ], "text/plain": [ "