Test loop

Benchmark created on


Test runner

Ready to run.

Testing in
TestOps/sec
For loop
let acc = 0;
let i = 0
for(; i < 10000; i+=2)
    if( i % 4 )
        ++acc;
    
console.log(acc, i);
ready
Bigint
let acc = 0;
let i = 0n
for(; i < 10000n; i+=2n)
    if( i % 4n)
        ++acc;
    
console.log(acc, i);
ready
BigIntArray
let data  = new BigInt64Array(3)
let iter = data[0] = 0n
let end  = data[1] = 10000n
let step = data[2] = 2n
let i = data[0]

let acc = 0;

for( ; iter < end; i = iter+=step)
      if( i % 4n )
          ++acc;
      
console.log(acc, iter)
ready
BigIntArray II
let data  = new BigInt64Array(4)
data[0] = 0n
let end  = data[1] = 10000n
let step = data[2] = 2n

let acc = 0;

for( ; data[0] < end; data[3] = data[0]+=step)
      if( data[3] % 4n )
          ++acc;
      
console.log(acc, data[0])
ready
For loop i is bigint
let acc = 0;
let i = 0
for(; i < 10000; i+=2)
    if( BigInt(i) % 4n )
        ++acc;
    
console.log(acc, i);
ready
For loop i is BigInt64Array
let acc = 0;
let i = new BigInt64Array(3)
let n = i[1] = 4n

let iter = 0
for( ; iter < 10000; iter+=2)
    if( (i[0] = BigInt(iter) ) % n )
        ++acc;
    
console.log(acc, iter);
ready
BigIntArray III
let data  = new BigInt64Array(4)
let iter = data[0] = 0n
let end  = data[1] = 10000n
let step = data[2] = 2n
let i = data[0]

let n = data[3] = 4n

let acc = 0;

for( ; iter < end; i = iter+=step)
      if( i % n )
          ++acc;
      
console.log(acc, iter)
ready

Revisions

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