Trivial quadratic search example

JavaScript performance comparison

Test case created by Ville Heikkinen

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
O(N²) - 10
const input = [1,2,3,4,5,6,8,9,10]

const subset = [8,9,10]

const result = input.filter(e => subset.includes(e))
pending…
O(N) - 10
const input = [1,2,3,4,5,6,8,9,10]

const subset = {8: true, 9: true, 10: true}

const result = input.filter(e => subset[e] === true)
pending…
O(N²) - 20
const input = [1,2,3,4,5,6,8,9,10,11,12,13,14,15,16,17,18,19,20]

const subset = [8,9,10,11,12,13]

const result = input.filter(e => subset.includes(e))
pending…
O(N) - 20
const input = [1,2,3,4,5,6,8,9,10,11,12,13,14,15,16,17,18,19,20]

const subset = {8: true, 9: true, 10: true, 11: true, 12: true, 13: true}

const result = input.filter(e => subset[e] === true)
pending…
O(N²) - 40
const input = [1,2,3,4,5,6,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40]

const subset = [8,9,10,11,12,13,14,15,16,17,18]

const result = input.filter(e => subset.includes(e))
pending…
O(N) - 40
const input = [1,2,3,4,5,6,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40]

const subset = {8: true, 9: true, 10: true, 11: true, 12: true, 13: true, 14: true, 15: true, 16: true, 17: true, 18: true}

const result = input.filter(e => subset[e] === true)
pending…

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

0 Comments