Back to Scalene

An example program to profile

docs/scalene-demo.ipynb

2.2.1640 B
Original Source
python
# An example program to profile

import numpy as np

def test_me():
    for i in range(6):
        x = np.array(range(10**7))
        y = np.array(np.random.uniform(0, 100, size=(10**8)))

python
# Load Scalene
%load_ext scalene
python
# Profile just one line of code
%scrun test_me()
python
# A full list of options
%scrun --help
python
# Generate a reduced profile (only lines with non-zero counts)
%scrun --reduced-profile test_me()
python
%%scalene --reduced-profile
# Profile more than one line of code in a cell
x = 0
for i in range(1000):
    for j in range(1000):
        x += 1