Skip to content

bench: add missing native benchmark#13325

Merged
kgryte merged 2 commits into
developfrom
philipp/drift-math-base-special-2026-07-06
Jul 6, 2026
Merged

bench: add missing native benchmark#13325
kgryte merged 2 commits into
developfrom
philipp/drift-math-base-special-2026-07-06

Conversation

@Planeshifter

Copy link
Copy Markdown
Member

Description

Adds the missing benchmark/benchmark.native.js to @stdlib/math/base/special/log1pmx so its N-API addon has the same JS-level benchmark surface as its 342 siblings in @stdlib/math/base/special.

Namespace summary

  • Namespace: @stdlib/math/base/special
  • Members analyzed: 357 packages, none autogenerated.
  • Native subset: 343 packages ship a native N-API addon (binding.gyp + src/addon.c + lib/native.js); 14 are pure-JS by design.
  • Features with a clear majority (≥75%): the shared file tree (README.md, lib/index.js, lib/main.js, docs/repl.txt, docs/types/{index.d.ts,test.ts}, test/test.js, benchmark/benchmark.js, examples/index.js, package.json), the standard package.json key set, and the H2 section list (Usage, Examples, C APIs for native packages). Among the 343 native packages, benchmark/benchmark.native.js and test/test.native.js are each present at 342/343.
  • Features excluded (no clear majority): the stdlib package.json sub-key set (only 249/357 packages carry a __stdlib__ block, below the 75% cutoff — likely a build-time addition, deliberately not touched here); the H2 See Also section (237/357, generator-owned per the routine's auto-populated gate).

math/base/special/log1pmx

log1pmx is the sole native package in the namespace missing benchmark/benchmark.native.js — 342 of 343 native siblings (99.7%) carry it, including the immediate sibling log1p. The package already ships a functional N-API addon (binding.gyp, src/{addon.c,main.c}, lib/native.js), so the gap is a bookkeeping oversight from when the package was added, not an intentional deviation. The new file mirrors log1p/benchmark/benchmark.native.js verbatim in structure — loads the addon via tryRequire('./../lib/native.js'), skips cleanly when the addon isn't built, and reuses the JS benchmark's uniform( 100, -1.0, 99.0 ) input distribution so JS and native numbers are comparable. No other file in the package changes, and nothing in test/, examples/, README.md, or docs/repl.txt — nor anywhere else in the repo — references or depends on the file's absence.

Related Issues

None.

Questions

No.

Other

Validation

  • Structural extraction over all 357 members — file trees, package.json key sets, manifest.json key sets, and README H2/H3 section lists — computed the majority pattern per feature at the routine's 75% threshold.
  • Semantic extraction via per-package agents was skipped for this run because structural drift alone surfaced a clear, single-file correction; the namespace is dense enough (357 members) that a per-package semantic pass would have burned rate limits for no gain against the specific finding already in hand.
  • Three-agent drift validation (opus semantic-review, opus cross-reference, sonnet structural-review) each independently returned confirmed-drift for the log1pmx finding.
  • Cross-run dedup against open PRs on the namespace: PR test: add special value tests for log1pmx #9491 modifies log1pmx/test/test.js (adding special-value tests) and PR docs: fix TSDoc issues across many math/base/special declarations #12467 revises TSDoc across math/base/special; neither touches benchmark/benchmark.native.js in log1pmx and neither collides at the file level.

Deliberately excluded:

  • log1pmx/test/test.native.js (also missing, 342/343 conformance). Adding it would mirror test/test.js, which PR test: add special value tests for log1pmx #9491 is actively extending; landing a test.native.js derived from today's test.js would silently omit the special-value tests once test: add special value tests for log1pmx #9491 merges. Deferred until test: add special value tests for log1pmx #9491 lands.
  • cfloor/benchmark/c/native/{Makefile,benchmark.c} (native package, 340/343 conformance for this pair). cfloor's existing benchmark/c/benchmark.c is a raw-C reference (calls floor() on creal(z)/cimag(z)); adding a stdlib-impl native benchmark would require writing ~140 lines of C that construct stdlib_complex128_t inputs and format Complex128 outputs — beyond the routine's mechanical-fix criterion.
  • hyp2f1/benchmark/c/native/{Makefile,benchmark.c} and sqrtpif/benchmark/c/native/{Makefile,benchmark.c} (same 340/343 conformance). Both packages have benchmark/c/benchmark.c files that already #include "stdlib/math/base/special/*.h" and call stdlib_base_* — content-wise they belong under benchmark/c/native/. The correction is a directory move plus Makefile CFLAGS rework, not a pure file addition, so it needs a human call on whether to move or duplicate; dropped from this run.
  • The fast sub-namespace parent (single-outlier missing lib/main.js, benchmark/benchmark.js, docs/repl.txt). It is a namespace package, not a leaf; deviation is intentional.
  • Autogenerated ## See Also sections (237/357), per the routine's auto-populated gate.

Checklist

AI Assistance

  • Yes
  • No

If you answered "yes" above, how did you use AI assistance?

  • Code generation (e.g., when writing an implementation or fixing a bug)
  • Test/benchmark generation
  • Documentation (including examples)
  • Research and understanding

Disclosure

This PR was authored by Claude Code on behalf of @Planeshifter as a cross-package drift audit of @stdlib/math/base/special. Structural features (file trees, package.json shape, README sections, manifest shape) were extracted for all 357 members; majority patterns were computed at the routine's 75% threshold; the single surviving outlier finding was independently validated by three reviewer agents (opus semantic-review, opus cross-reference, sonnet structural-review). A human will audit and promote the PR out of draft.


@stdlib-js/reviewers


Generated by Claude Code

Adds `benchmark/benchmark.native.js` to exercise the native N-API addon
via `tryRequire( './../lib/native.js' )`, mirroring the sibling pattern
already present in 342 of 343 (99.7%) native packages under
`@stdlib/math/base/special` (e.g. `log1p/benchmark/benchmark.native.js`).
The benchmark reuses the JS benchmark's `uniform( 100, -1.0, 99.0 )`
input distribution and skips when the addon is not built.
@stdlib-bot stdlib-bot added the Math Issue or pull request specific to math functionality. label Jul 6, 2026
Fixes the `Lint Copyright Years` CI check on the newly added
`log1pmx/benchmark/benchmark.native.js`, which requires the current
year in the copyright header for newly added files.
@stdlib-bot

stdlib-bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Coverage Report

Package Statements Branches Functions Lines
math/base/special/log1pmx $\\color{green}207/207$
$\\color{green}+100.00\\%$
$\\color{green}12/12$
$\\color{green}+100.00\\%$
$\\color{green}3/3$
$\\color{green}+100.00\\%$
$\\color{green}207/207$
$\\color{green}+100.00\\%$

The above coverage report was generated for the changes in this PR.

@Planeshifter Planeshifter marked this pull request as ready for review July 6, 2026 16:56
@Planeshifter Planeshifter requested review from a team and kgryte July 6, 2026 16:56
@stdlib-bot stdlib-bot added the Needs Review A pull request which needs code review. label Jul 6, 2026
@kgryte kgryte added Benchmarks Pull requests adding or improving benchmarks for measuring performance. and removed Needs Review A pull request which needs code review. labels Jul 6, 2026
@kgryte kgryte changed the title bench: add missing native benchmark to math/base/special/log1pmx bench: add missing native benchmark Jul 6, 2026
@kgryte kgryte merged commit 1a2e90a into develop Jul 6, 2026
52 checks passed
@kgryte kgryte deleted the philipp/drift-math-base-special-2026-07-06 branch July 6, 2026 23:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Benchmarks Pull requests adding or improving benchmarks for measuring performance. Math Issue or pull request specific to math functionality.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants