proof of work test with different input lengths

Benchmark created on


Setup

async function digest(size) {
const msg = crypto.getRandomValues(new Uint8Array(size));	
  const len = msg.length;
  const arr = new Uint8Array(len + 6);
  arr.set(msg, 0);
  let i = 0;
  while (i++ < 2e14) {
    for (let j = 5, bits = i; j >= 0; --j) {
      arr[len + j] = bits & 0xff;
      bits >>= 8;
    }
    const hash = await window.crypto.subtle.digest("SHA-256", arr);
    const res = new Uint8Array(hash);
    if (res[0] === 0 && res[1] === 0 && res[2] !== 0) {
      return i;
    }
  }
  return -1;
}

Test runner

Ready to run.

Testing in
TestOps/sec
16
digest(16).then(t=>deferred.resolve(t))
ready
20
digest(20).then(t=>deferred.resolve(t))
ready
24
digest(24).then(t=>deferred.resolve(t))
ready
30
digest(30).then(t=>deferred.resolve(t))
ready

Revisions

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