Jupyter magic for measuring I/O operations per second
Project description
iops-profiler
A Jupyter IPython magic extension for measuring I/O operations per second (IOPS) in your code.
Installation
You can install iops-profiler directly from PyPI (once published):
pip install iops-profiler
Or install from source:
git clone https://github.com/lincc-frameworks/iops-profiler.git
cd iops-profiler
pip install -e .
Usage
Load the extension in your Jupyter notebook:
%load_ext iops_profiler
Line Magic Mode
Use the %iops line magic to profile a single line of code:
%iops open('test.txt', 'w').write('Hello World' * 1000)
Cell Magic Mode
Use the %%iops cell magic to profile I/O operations in an entire cell:
%%iops
# Your code here
with open('test.txt', 'w') as f:
f.write('Hello World' * 1000)
The extension will display a table showing:
- Execution time
- Read/write operation counts
- Bytes read/written
- IOPS (operations per second)
- Throughput (bytes per second)
Histogram Visualization
Use the --histogram flag to visualize I/O operation distributions (available for strace and fs_usage measurement modes):
Example - Analyzing I/O patterns with multiple file sizes:
%%iops --histogram
import tempfile
import os
import shutil
# Create test files with different sizes
test_dir = tempfile.mkdtemp()
try:
# Write files of various sizes to create diverse write operations
# Small writes (few KB)
for i in range(5):
with open(os.path.join(test_dir, f'small_{i}.txt'), 'w') as f:
f.write('x' * 1024) # 1 KB
# Medium writes (tens of KB)
for i in range(3):
with open(os.path.join(test_dir, f'medium_{i}.txt'), 'w') as f:
f.write('y' * (10 * 1024)) # 10 KB
# Large writes (hundreds of KB)
for i in range(2):
with open(os.path.join(test_dir, f'large_{i}.txt'), 'w') as f:
f.write('z' * (100 * 1024)) # 100 KB
# Now read back the files to create diverse read operations
# Small reads
for i in range(5):
with open(os.path.join(test_dir, f'small_{i}.txt'), 'r') as f:
_ = f.read()
# Medium reads
for i in range(3):
with open(os.path.join(test_dir, f'medium_{i}.txt'), 'r') as f:
_ = f.read()
# Large reads
for i in range(2):
with open(os.path.join(test_dir, f'large_{i}.txt'), 'r') as f:
_ = f.read()
finally:
# Cleanup
if os.path.exists(test_dir):
shutil.rmtree(test_dir)
This example generates a rich distribution of I/O operations across multiple size ranges, producing histograms like:
When enabled, two histogram charts are displayed alongside the results table:
- Operation Count Distribution: Shows the count of I/O operations bucketed by bytes-per-operation (log scale)
- Total Bytes Distribution: Shows the total bytes transferred bucketed by bytes-per-operation (log scale)
Both charts display separate lines for reads, writes, and all operations combined, making it easy to identify patterns in your code's I/O behavior.
Platform Support
- Linux/Windows: Uses
psutilfor per-process I/O tracking - macOS: Uses
fs_usagewith privilege elevation (requires password prompt)
Requirements
- Python 3.10+
- IPython/Jupyter
- psutil
- matplotlib (for histogram visualization)
- numpy (for histogram visualization)
Dev Guide - Getting Started
Before installing any dependencies or writing code, it's a great idea to create a
virtual environment. LINCC-Frameworks engineers primarily use conda to manage virtual
environments. If you have conda installed locally, you can run the following to
create and activate a new environment.
conda create -n <env_name> python=3.10
conda activate <env_name>
Once you have created a new environment, you can install this project for local development using the following commands:
pip install -e '.[dev]'
pre-commit install
Notes:
- The install command will install the package in editable mode with all development dependencies
pre-commit installwill initialize pre-commit for this local repository, so that a set of tests will be run prior to completing a local commit. For more information, see the Python Project Template documentation on pre-commit
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file iops_profiler-0.2.0.tar.gz.
File metadata
- Download URL: iops_profiler-0.2.0.tar.gz
- Upload date:
- Size: 99.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1cf4564821a98200ca57c3e06f7a672bb9b67e73346765973126f258edea153d
|
|
| MD5 |
376e974b390ee89e4c85a14fdf86b9e8
|
|
| BLAKE2b-256 |
a00e3c4fbdbe4d959a401140985b35d35f70edb4a837fd805eb33c00b2d3c1b4
|
Provenance
The following attestation bundles were made for iops_profiler-0.2.0.tar.gz:
Publisher:
publish-to-pypi.yml on lincc-frameworks/iops-profiler
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
iops_profiler-0.2.0.tar.gz -
Subject digest:
1cf4564821a98200ca57c3e06f7a672bb9b67e73346765973126f258edea153d - Sigstore transparency entry: 673630201
- Sigstore integration time:
-
Permalink:
lincc-frameworks/iops-profiler@6c21e28f8c7b02f186433a8169bbf141f44472e1 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/lincc-frameworks
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@6c21e28f8c7b02f186433a8169bbf141f44472e1 -
Trigger Event:
release
-
Statement type:
File details
Details for the file iops_profiler-0.2.0-py3-none-any.whl.
File metadata
- Download URL: iops_profiler-0.2.0-py3-none-any.whl
- Upload date:
- Size: 15.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aae996bb56527963a255507a7c3200715bfc56efc25281a21226584cf1b8e719
|
|
| MD5 |
99965204199e8cfd6759fd45e614ec08
|
|
| BLAKE2b-256 |
bf62e13e4f8ffa11f41ad22305c067b8c67a2eeee9be440dd6f249cf3ef58eb8
|
Provenance
The following attestation bundles were made for iops_profiler-0.2.0-py3-none-any.whl:
Publisher:
publish-to-pypi.yml on lincc-frameworks/iops-profiler
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
iops_profiler-0.2.0-py3-none-any.whl -
Subject digest:
aae996bb56527963a255507a7c3200715bfc56efc25281a21226584cf1b8e719 - Sigstore transparency entry: 673630217
- Sigstore integration time:
-
Permalink:
lincc-frameworks/iops-profiler@6c21e28f8c7b02f186433a8169bbf141f44472e1 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/lincc-frameworks
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@6c21e28f8c7b02f186433a8169bbf141f44472e1 -
Trigger Event:
release
-
Statement type: