From b2c60361c0d4e3899148bdc4aedcafff1d426d0d Mon Sep 17 00:00:00 2001 From: Copilot <198982749+Copilot@users.noreply.github.com> Date: Wed, 4 Mar 2026 19:17:45 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=9D=20Extract=20comparison=20section?= =?UTF-8?q?=20from=20README=20into=20separate=20document=20(#880)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Moves the detailed benchmark comparison (tables, methodology, system details) out of the README into `COMPARISON.md`. - **README.md**: Comparison section trimmed to the chart image, a one-liner on the benefit (performance + built-in uniform distributions), and a link to the full doc - **COMPARISON.md**: New file containing the full extracted content (summary, process, benchmark tables, system details) - Fixed pre-existing typo ("aked" → "asked") in the extracted content
Original prompt > extract the comparison section outside of the readme but link it from the README. keep just the bare minimal possibly the picture and a few lines to explain the benefit over others
--- 💬 We'd love your input! Share your thoughts on Copilot coding agent in our [2 minute survey](https://gh.io/copilot-coding-agent-survey). --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: dubzzz <5300235+dubzzz@users.noreply.github.com> --- COMPARISON.md | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++ README.md | 59 ++---------------------------------------------- 2 files changed, 64 insertions(+), 57 deletions(-) create mode 100644 COMPARISON.md diff --git a/COMPARISON.md b/COMPARISON.md new file mode 100644 index 0000000..96c75b4 --- /dev/null +++ b/COMPARISON.md @@ -0,0 +1,62 @@ +# Comparison + +## Summary + +The chart has been split into three sections: + +- section 1: native `Math.random()` +- section 2: without uniform distribution of values +- section 3: with uniform distribution of values (not supported by all libraries) + +Comparison against other libraries + +## Process + +In order to compare the performance of the libraries, we asked them to shuffle an array containing 1,000,000 items (see [code](https://github.com/dubzzz/pure-rand/blob/556ec331c68091c5d56e9da1266112e8ea222b2e/perf/compare.cjs)). + +We then split the measurements into two sections: + +- one for non-uniform distributions — _known to be slower as it implies re-asking for other values to the PRNG until the produced value fall into the acceptable range of values_ +- one for uniform distributions + +The recommended setup for pure-rand is to rely on our Xoroshiro128+. It provides a long enough sequence of random values, has built-in support for jump, is really efficient while providing a very good quality of randomness. + +## Performance + +**Non-Uniform** + +| Library | Algorithm | Mean time (ms) | Compared to pure-rand | +| ------------------------ | ----------------- | -------------- | --------------------- | +| native \(node 16.19.1\) | Xorshift128+ | 33.3 | 1.4x slower | +| **pure-rand _@6.0.0_** | **Xoroshiro128+** | **24.5** | **reference** | +| pure-rand _@6.0.0_ | Xorshift128+ | 25.0 | similar | +| pure-rand _@6.0.0_ | Mersenne Twister | 30.8 | 1.3x slower | +| pure-rand _@6.0.0_ | Congruential‍ | 22.6 | 1.1x faster | +| seedrandom _@3.0.5_ | Alea | 28.1 | 1.1x slower | +| seedrandom _@3.0.5_ | Xorshift128 | 28.8 | 1.2x slower | +| seedrandom _@3.0.5_ | Tyche-i | 28.6 | 1.2x slower | +| seedrandom _@3.0.5_ | Xorwow | 32.0 | 1.3x slower | +| seedrandom _@3.0.5_ | Xor4096 | 32.2 | 1.3x slower | +| seedrandom _@3.0.5_ | Xorshift7 | 33.5 | 1.4x slower | +| @faker-js/faker _@7.6.0_ | Mersenne Twister | 109.1 | 4.5x slower | +| chance _@1.1.10_ | Mersenne Twister | 142.9 | 5.8x slower | + +**Uniform** + +| Library | Algorithm | Mean time (ms) | Compared to pure-rand | +| ---------------------- | ----------------- | -------------- | --------------------- | +| **pure-rand _@6.0.0_** | **Xoroshiro128+** | **53.5** | **reference** | +| pure-rand _@6.0.0_ | Xorshift128+ | 52.2 | similar | +| pure-rand _@6.0.0_ | Mersenne Twister | 61.6 | 1.2x slower | +| pure-rand _@6.0.0_ | Congruential‍ | 57.6 | 1.1x slower | +| random-js @2.1.0 | Mersenne Twister | 119.6 | 2.2x slower | + +> System details: +> +> - OS: Linux 5.15 Ubuntu 22.04.2 LTS 22.04.2 LTS (Jammy Jellyfish) +> - CPU: (2) x64 Intel(R) Xeon(R) Platinum 8272CL CPU @ 2.60GHz +> - Memory: 5.88 GB / 6.78 GB +> - Container: Yes +> - Node: 16.19.1 - /opt/hostedtoolcache/node/16.19.1/x64/bin/node +> +> _Executed on default runners provided by GitHub Actions_ diff --git a/README.md b/README.md index 063caf4..362fd7e 100644 --- a/README.md +++ b/README.md @@ -151,66 +151,11 @@ Each of these helpers come with its own import: `pure-rand/utils/`. ## Comparison -### Summary - -The chart has been split into three sections: - -- section 1: native `Math.random()` -- section 2: without uniform distribution of values -- section 3: with uniform distribution of values (not supported by all libraries) +pure-rand offers competitive performance compared to other PRNG libraries, with built-in support for uniform distributions — ensuring unbiased results out of the box. Comparison against other libraries -### Process - -In order to compare the performance of the libraries, we aked them to shuffle an array containing 1,000,000 items (see [code](https://github.com/dubzzz/pure-rand/blob/556ec331c68091c5d56e9da1266112e8ea222b2e/perf/compare.cjs)). - -We then split the measurements into two sections: - -- one for non-uniform distributions — _known to be slower as it implies re-asking for other values to the PRNG until the produced value fall into the acceptable range of values_ -- one for uniform distributions - -The recommended setup for pure-rand is to rely on our Xoroshiro128+. It provides a long enough sequence of random values, has built-in support for jump, is really efficient while providing a very good quality of randomness. - -### Performance - -**Non-Uniform** - -| Library | Algorithm | Mean time (ms) | Compared to pure-rand | -| ------------------------ | ----------------- | -------------- | --------------------- | -| native \(node 16.19.1\) | Xorshift128+ | 33.3 | 1.4x slower | -| **pure-rand _@6.0.0_** | **Xoroshiro128+** | **24.5** | **reference** | -| pure-rand _@6.0.0_ | Xorshift128+ | 25.0 | similar | -| pure-rand _@6.0.0_ | Mersenne Twister | 30.8 | 1.3x slower | -| pure-rand _@6.0.0_ | Congruential‍ | 22.6 | 1.1x faster | -| seedrandom _@3.0.5_ | Alea | 28.1 | 1.1x slower | -| seedrandom _@3.0.5_ | Xorshift128 | 28.8 | 1.2x slower | -| seedrandom _@3.0.5_ | Tyche-i | 28.6 | 1.2x slower | -| seedrandom _@3.0.5_ | Xorwow | 32.0 | 1.3x slower | -| seedrandom _@3.0.5_ | Xor4096 | 32.2 | 1.3x slower | -| seedrandom _@3.0.5_ | Xorshift7 | 33.5 | 1.4x slower | -| @faker-js/faker _@7.6.0_ | Mersenne Twister | 109.1 | 4.5x slower | -| chance _@1.1.10_ | Mersenne Twister | 142.9 | 5.8x slower | - -**Uniform** - -| Library | Algorithm | Mean time (ms) | Compared to pure-rand | -| ---------------------- | ----------------- | -------------- | --------------------- | -| **pure-rand _@6.0.0_** | **Xoroshiro128+** | **53.5** | **reference** | -| pure-rand _@6.0.0_ | Xorshift128+ | 52.2 | similar | -| pure-rand _@6.0.0_ | Mersenne Twister | 61.6 | 1.2x slower | -| pure-rand _@6.0.0_ | Congruential‍ | 57.6 | 1.1x slower | -| random-js @2.1.0 | Mersenne Twister | 119.6 | 2.2x slower | - -> System details: -> -> - OS: Linux 5.15 Ubuntu 22.04.2 LTS 22.04.2 LTS (Jammy Jellyfish) -> - CPU: (2) x64 Intel(R) Xeon(R) Platinum 8272CL CPU @ 2.60GHz -> - Memory: 5.88 GB / 6.78 GB -> - Container: Yes -> - Node: 16.19.1 - /opt/hostedtoolcache/node/16.19.1/x64/bin/node -> -> _Executed on default runners provided by GitHub Actions_ +For detailed benchmark results and methodology, see the [full comparison](./COMPARISON.md). --- -- 2.51.2