Skip to content

Add Python operator performance benchmarks - #523

Open
aarya18dh wants to merge 3 commits into
csrc-sdsu:mainfrom
aarya18dh:feature/python-performance-benchmarks
Open

aarya18dh wants to merge 3 commits into
csrc-sdsu:mainfrom
aarya18dh:feature/python-performance-benchmarks

Conversation

@aarya18dh

Copy link
Copy Markdown

What type of PR is this? (check all applicable)

  • Refactor
  • Feature
  • Bug Fix
  • Optimization
  • Example
  • Documentation

Description

This pull request adds a reproducible Python performance-benchmarking suite for the existing MOLE mimetic operators.

The benchmark measures:

  • Operator construction time
  • Sparse matrix-vector application time
  • Performance across increasing one-dimensional and two-dimensional grids
  • Mean, median, minimum, maximum, and standard deviation from repeated measurements
  • Matrix dimensions and numbers of nonzero entries
  • Dense matrix-vector application for small grids

The benchmark includes Gradient, Divergence, and Laplacian for one-dimensional and two-dimensional grids. Curl is included for two-dimensional grids because the current MOLE Python API supports Curl only in 2D.

The underlying mathematical implementations are not modified.

Related Issues & Documents

QA Instructions, Screenshots, Recordings

From the root directory of the MOLE repository, install the local Python package if necessary:

python -m pip install -e ./python

Keep-open request

  • I am requesting maintainer review for keep-open.

Reason: This contribution is ready for maintainer review. I am requesting that the pull request remain open while maintainers provide feedback on the benchmark design, output format, and documentation.

Added/updated tests?

_We encourage you to test all code included with MOLE, including examples.

  • Yes
  • No, and this is why: The contribution adds an executable benchmark and documentation without modifying the mathematical implementations. The benchmark was manually executed for both 1D and 2D grids, including sparse and small-grid dense matrix application. I would appreciate maintainer guidance on whether additional automated tests should be added.
  • I need help with writing tests

Read Contributing Guide and Code of Conduct

@cpaolini cpaolini self-assigned this Nov 19, 2026
@cpaolini

Copy link
Copy Markdown
Collaborator

@aarya18dh Since the actual matrix construction occurs in each operator's constructor .init(), invoking .matrix reconstructs the matrix rather than returning the matrix already built by the constructor, which increases the timing. You can remove the call to .matrix in benchmark_operators.py to get a more accurate timing.

@aarya18dh

Copy link
Copy Markdown
Author

Thank you for pointing this out. I removed the .matrix access from the construction-timing function so the timing now measures only the operator constructor. The matrix is still created separately for the application benchmark.

@cpaolini
cpaolini self-requested a review November 21, 2026 01:18
@codecov

codecov Bot commented Nov 21, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@cpaolini cpaolini left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I approve this PR.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a reproducible Python benchmark suite for MOLE mimetic operators

2 participants