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

philihp / pcg / 26025512348
100%

Build:
DEFAULT BRANCH: main
Ran 18 May 2026 09:38AM 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 09:37AM UTC coverage: 88.976% (-11.0%) from 100.0%
26025512348

push

github

web-flow
perf: ~7× faster randomInt/nextState/randomList hot path (#328)

* perf: hot-path optimizations for randomInt/nextState/randomList

The dominant consumer of this library — fast-shuffle — calls randomInt
in a tight loop, where each call goes through nextState. Three changes
remove most of the per-call overhead:

- nextState now does the simple PCG step (state * multiplier + increment)
  directly, instead of dispatching through stepState's curry + jump-ahead
  bookkeeping loop. stepState(1) was running a 1-iteration loop while
  allocating a handful of extra Longs each call.
- randomInt no longer wraps the output number in Long inside the
  rejection loop; the threshold and modulo are done with plain JS
  arithmetic. Values fit in safe-integer range so semantics are
  preserved.
- randomList replaces ramda.scan with a direct for loop, avoiding
  the iterator + accumulator allocations.

Microbenchmarks (Node, 1M iters where applicable):

  nextState              381k -> 3,301k ops/s  (8.7x)
  randomInt(0, 100)      323k -> 2,230k ops/s  (6.9x)
  shuffle-style 100 ints 6.0k -> 44.1k ops/s   (7.3x)
  randomList(100)        5.9k -> 41.6k ops/s   (7.1x)

All existing tests pass with identical output bits.

* refactor: drop long dependency in favor of native bigint

Replaces the long runtime dependency with native BigInt for all 64-bit
arithmetic. Masking with 0xFFFFFFFFFFFFFFFFn after each multiplication or
addition keeps values in the uint64 range. Output bits are bit-identical
to the previous Long-based implementation across all four output
functions and all three stream schemes.

API-wise, the LongLike alias is preserved as a public type name and is
now `bigint | number | string` (which is what the previous Long-based
implementation effectively accepted). PCGState.state, PCGConfig.multiplier,
and PCGConfig.increment are now `bigint` instead of `Long`.

Benchmarks (Node, microbench vs original Long-based main):

  nextState              381k -> 2,865k ops/... (continued)

24 of 32 branches covered (75.0%)

Branch coverage included in aggregate %.

48 of 53 new or added lines in 3 files covered. (90.57%)

1 existing line in 1 file now uncovered.

89 of 95 relevant lines covered (93.68%)

4855.35 hits per line

Uncovered Changes

Lines Coverage ∆ File
5
84.44
-15.56% src/createPcg.ts

Coverage Regressions

Lines Coverage ∆ File
1
84.44
-15.56% src/createPcg.ts
Jobs
ID Job ID Ran Files Coverage
1 26025512348.1 18 May 2026 09:38AM UTC 5
88.98
GitHub Action Run
Source Files on build 26025512348
  • Tree
  • List 5
  • Changed 4
  • Source Changed 0
  • Coverage Changed 4
Coverage ∆ File Lines Relevant Covered Missed Hits/Line Branch Hits Branch Misses
  • Back to Repo
  • 9a9fd90f on github
  • Prev Build on main (#25968243163)
  • Next Build on main (#26026019871)
  • 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