BigInt::asUintN or BigInt::operator&

Benchmark created on


Setup

class Thrust1 {
  constructor(seed) {
    this.state = seed | 1n;
  }
  randomUint64() {
    const s = this.state;
    this.state = this.state + 0x6a5d39eae12657aan & 18446744073709551615n;
    const z = (s ^ s >> 25n) * this.state & 18446744073709551615n;
    return z ^ z >> 22n;
  }
}

class Thrust2 {
    constructor(seed) {
        this.state = seed | 1n;
    }
    randomUint64() {
        const s = this.state;
        this.state = BigInt.asUintN(64, this.state + 0x6a5d39eae12657aan);
        const z = BigInt.asUintN(64, (s ^ (s >> 25n)) * this.state);
        return z ^ (z >> 22n);
    }
}

const thrust1 = new Thrust1(255n)
const thrust2 = new Thrust2(255n)
let counter = 0n

Test runner

Ready to run.

Testing in
TestOps/sec
operator&
counter += thrust1.randomUint64()

ready
asUintN
counter += thrust2.randomUint64()

ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.