• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

philihp / pcg / 26031894998
100%

Build:
DEFAULT BRANCH: main
Ran 18 May 2026 11:55AM UTC
Jobs 1
Files 5
Run time 1min
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

18 May 2026 11:54AM UTC coverage: 90.441% (+0.9%) from 89.51%
26031894998

push

github

web-flow
perf: move scheme→increment dispatch to the PCG config (#331)

* perf: move scheme→increment dispatch to the PCG config

Replace the inline ternary in nextState and the per-call 3-closure
incrementers object in stepStateImpl with a single getIncrement(pcg)
function stored on PCGConfig. Each variant supplies its own dispatch,
keeping all three schemes (SETSEQ, ONESEQ, MCG) intact.

Benchmarked vs origin/main:
- stepState(1_000_000): 5269 → 4468 ns/op (~15% faster)
- nextState / randomInt / randomList: noise (~3%)
- JSON round-trip: unchanged

The stepState win comes from dropping the per-call closure object
allocation. nextState was already inlined as a ternary so it doesn't
move much.

Also tried caching toBigInt(pcg.state) and toBigInt(pcg.streamId) via a
WeakMap side-table; on V8 the map ops cost roughly as much as the
BigInt allocations they replace, so it regressed nextState by ~2×.
A non-enumerable property cache would have been faster but breaks
serialize.test.ts's toStrictEqual (Jest compares own non-enumerable
and symbol keys). No cache shipped.

https://claude.ai/code/session_01PYpJLhJYgJWZWzH8xjRFte

* refactor: dispatch increment via Record<StreamScheme, SchemeFn>

Replace the chained if/else in createPcg32's getIncrement with a hash
lookup on a Record keyed by StreamScheme, matching the original shape
of the incrementers object that used to be allocated inside
stepStateImpl on every call.

The Record now lives on PCGConfig (allocated once per variant), and
both nextState and stepStateImpl dispatch via
`config.incrementers[pcg.streamScheme](pcg)`.

SchemeFn updated to take pcg so the SETSEQ branch can read streamId.

Benchmarks unchanged from the prior if/else version — V8 inline-caches
the property access:
- nextState: 424 ns/op (was 423)
- stepState(1_000_000): 4467 ns/op (was 4468)

https://claude.ai/code/session_01PYpJLhJYgJWZWzH8xjRFte

---------

Co-authored-by: Claude <noreply@anthropic.com>

21 of 30 branches covered (70.0%)

Branch coverage included in aggregate %.

6 of 6 new or added lines in 2 files covered. (100.0%)

102 of 106 relevant lines covered (96.23%)

13041.38 hits per line

Jobs
ID Job ID Ran Files Coverage
1 26031894998.1 18 May 2026 11:55AM UTC 5
90.44
GitHub Action Run
Source Files on build 26031894998
  • Tree
  • List 5
  • Changed 3
  • Source Changed 0
  • Coverage Changed 3
Coverage ∆ File Lines Relevant Covered Missed Hits/Line Branch Hits Branch Misses
  • Back to Repo
  • 8034056d on github
  • Prev Build on main (#26028074792)
  • Next Build on main (#26034673913)
  • Delete
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc