Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
xoshiro128** various implementations
(version: 0)
Comparing performance of:
Xoshiro128StarStar vs Xoshiro128StarStar2
Created:
one year ago
by:
Registered User
Jump to the latest result
Script Preparation code:
class Xoshiro128StarStar { constructor(a, b, c, d) { this.a = a; this.b = b; this.c = c; this.d = d; } next() { const t = this.b << 9; let r = this.b * 5; r = ((r << 7) | (r >>> 25)) * 9; this.c ^= this.a; this.d ^= this.b; this.b ^= this.c; this.a ^= this.d; this.c ^= t; this.d = (this.d << 11) | (this.d >>> 21); return r >>> 0; // Ensure unsigned integer } } class Xoshiro128StarStar2 { constructor(a, b, c, d) { this.a = a; this.b = b; this.c = c; this.d = d; } next() { const s0 = this.a; const s1 = this.b; const s2 = this.c; const s3 = this.d; const x = s1 * 5; const r = (((x << 7) | (x >>> 25)) * 9) >>> 0; const t2 = s2 ^ s0; const t3 = s3 ^ s1; this.b = s1 ^ t2; this.a = s0 ^ t3; this.c = t2 ^ (s1 << 9); this.d = (t3 << 11) | (t3 >>> 21); return r; } } rngA = new Xoshiro128StarStar(3536, 4678, 2245, 778); rngB = new Xoshiro128StarStar2(3536, 4678, 2245, 778);
Tests:
Xoshiro128StarStar
for(let i = 0; i < 100; i++) { const z = rngA.next(); }
Xoshiro128StarStar2
for(let i = 0; i < 100; i++) { const z = rngB.next(); }
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
Xoshiro128StarStar
Xoshiro128StarStar2
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
10 months ago
)
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Safari/537.36
Browser/OS:
Chrome 137 on Windows
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
Xoshiro128StarStar
770711.4 Ops/sec
Xoshiro128StarStar2
1467687.1 Ops/sec
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
Let's dive into the explanation. **Benchmark Definition JSON** The provided benchmark definition is for testing two different implementations of the Xoshiro 128* StarStar (XRNG) random number generator, which is a widely used and high-quality pseudorandom number generator. **Script Preparation Code** The script preparation code defines two classes: `Xoshiro128StarStar` and `Xoshiro128StarStar2`. These classes are the core of the XRNG algorithm. The main difference between them lies in how they generate the next random value (`next()` function). Here's a brief overview: 1. **`Xoshiro128StarStar`**: * This implementation uses bitwise operations to combine and modify its internal state (`a`, `b`, `c`, and `d`) in each iteration. * The formula used is similar to the one described in the paper by Makoto Matsumoto (2009) for Xoshiro 128* StarStar. 2. **`Xoshiro128StarStar2`**: * This implementation also uses bitwise operations, but with some differences from `Xoshiro128StarStar`. * The formula used is similar to the one described in the paper by Makoto Matsumoto (2009) for Xoshiro 128* StarStar, but with a different initial state (`s0`, `s1`, `s2`, and `s3`) and how they are combined. **Options Compared** The benchmark compares two options: 1. **`Xoshiro128StarStar`**: This implementation uses the original formula for generating random numbers, which is considered to be one of the most efficient and reliable ways to generate high-quality pseudorandom numbers. 2. **`Xoshiro128StarStar2`**: This implementation modifies the initial state (`s0`, `s1`, `s2`, and `s3`) and how they are combined, which may affect its performance and quality. **Pros and Cons** Here are some pros and cons of each approach: * **`Xoshiro128StarStar`**: * Pros: It is widely used, known for its high-quality random numbers, and has a well-established reputation. * Cons: The formula can be complex to understand and implement. * **`Xoshiro128StarStar2`**: * Pros: This implementation may offer some performance improvements or slight variations in quality compared to the original `Xoshiro128StarStar`, depending on the specific use case. * Cons: The modifications to the initial state and formula may affect its overall quality, making it less suitable for all applications. **Other Considerations** When choosing an implementation of XRNG, consider the following factors: 1. **Performance**: If speed is a priority, `Xoshiro128StarStar2` might be faster due to simpler bitwise operations. 2. **Quality**: For most applications requiring high-quality random numbers, `Xoshiro128StarStar` is still the preferred choice. **Alternatives** Other alternatives for generating pseudorandom numbers include: 1. **Linear Congruential Generators (LCGs)**: These are simple and widely used but often have a lower quality compared to XRNGs. 2. **Mersenne Twisters**: These offer better randomness properties than LCGs, but can be slower. 3. **Fortuna PRNGs**: These are designed for high-quality random numbers and cryptographic applications. In conclusion, the choice between `Xoshiro128StarStar` and `Xoshiro128StarStar2` depends on specific requirements, such as performance or quality of randomness needed.
Related benchmarks:
Picon dev - insatnce of vs isPrototyOf
instanceOf-bitwise
Instantiation via ES6 Class vs Prototype vs Object Literal
Comparison of classes vs prototypes vs object literals also including the inheritance
ES6 Class vs Prototype vs Object Literal v2 with Extends
Comments
Confirm delete:
Do you really want to delete benchmark?