test

Benchmark publishedon

Setup

let a = [1,2,3,4,5,6,7,8,9]

Test Runner

Initializing...

Testing in
Test CaseOps/sec
mod forEach (O (n))
const fn = (col) => {
    a.forEach((value, index) =>  {
        if ((index) % 3 === col - 1) {
            console.log(value)
        }
    });
}

fn(1);
fn(2);
fn(3);
ready
mod for (O (n))
const fn = (col) => { 
	for (let i = 0; i < a.length; i++) {
		if (i % 3 === col - 1) {
			console.log(a[i]);
		}
	}
}

fn(1);
fn(2);
fn(3);
ready
filter (O (n))
const fn = (col) => { 
	console.log(a.filter((v, index) => index % 3 === col - 1));
}

fn(1);
fn(2);
fn(3);
ready
row traverse (O (n log n))
const fn = (col) => { 
	for (let i=0; i < a.length; i+=3) {
		console.log(a[i + col - 1])
	}
}

fn(1);
fn(2);
fn(3);
ready
relative index (O (n log n))
const fn = (col) => { 
	for (let i = col-1; i < a.length; i+=3) {
		console.log(a[i])
	}
}

fn(1);
fn(2);
fn(3);
ready
constant (O (const))
const fn = (col) => {
	console.log([
		a[3 * 0 + col - 1],
		a[3 * 1 + col - 1],
		a[3 * 2 + col - 1],
		
	])
}
ready

Revisions

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

Revision 1
publishedon
Revision 2
publishedon