Created
January 21, 2016 10:35
-
-
Save AdriVanHoudt/d797cb1397adc96f0525 to your computer and use it in GitHub Desktop.
Mini benchmark Hoek.unique vs Set
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Hoek = require('hoek'); | |
const array = []; | |
for (let i = 0; i < 5000000; ++i) { | |
array.push(i * Math.floor(Math.random() * (10 - 1 + 1)) + 1); | |
} | |
console.time('hoek'); | |
const result = []; | |
for (let i = 0; i < array.length; ++i) { | |
result.push(array[i]); | |
} | |
const resultHoek = Hoek.unique(result); | |
console.timeEnd('hoek') | |
console.time('set'); | |
const result2 = new Set(); | |
for (let i = 0; i < array.length; ++i) { | |
result2.add(array[i]); | |
} | |
const result2Set = Array.from(result2); | |
console.timeEnd('set') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment