Skip to content

BENCH: add scalar and array pmt benchmarks - #160

Open
naseweisssss wants to merge 3 commits into
numpy:mainfrom
naseweisssss:codex/pmt-asv-benchmarks
Open

naseweisssss wants to merge 3 commits into
numpy:mainfrom
naseweisssss:codex/pmt-asv-benchmarks

Conversation

@naseweisssss

@naseweisssss naseweisssss commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

Current output

benchmarks.Pmt.time_pmt    ok

======== ====== ============ =============
                         when
--------------- --------------------------
  size    rate      end          begin
======== ====== ============ =============
 scalar   0.0    19.3~0.4us    19.5~0.4us
 scalar   0.05   19.4~0.3us    19.6~0.3us
   1      0.0    20.4~0.3us    20.4~0.3us
   1      0.05    26.1~8us     20.7~0.3us
   10     0.0    20.8~0.3us   21.0~0.09us
   10     0.05   20.9~0.2us    20.7~0.2us
  1000    0.0    34.8~0.4us    34.7~0.3us
  1000    0.05   46.6~0.5us    47.2~0.4us
======== ====== ============ =============

For nonzero interest and end-of-period payments, a scalar call took 19.4 µs, compared with 20.9 µs for 10 loans and 46.6 µs for 1,000 loans.

These results support the hypothesis that fixed per-call overhead dominates small inputs. This PR does not discuss about the causes of this but just to show the results of the benchmark.

@naseweisssss

Copy link
Copy Markdown
Contributor Author

Added a scalar fast path in 157712e: ordinary floating-point scalar calls use NumPy scalar arithmetic without allocating arrays. Arrays, Decimal and other types retain the existing path. Paired timings show 6.9–7.9× faster scalar calls; 196 tests and lint/type checks passed on the implementation branch. Details: #36 (comment)

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

bench Related to benchmarking numpy-financial sustain-2026

Projects

Development

Successfully merging this pull request may close these issues.

2 participants