Skip to content

Instantly share code, notes, and snippets.

@AdriVanHoudt
Created January 21, 2016 10:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save AdriVanHoudt/d797cb1397adc96f0525 to your computer and use it in GitHub Desktop.
Save AdriVanHoudt/d797cb1397adc96f0525 to your computer and use it in GitHub Desktop.
Mini benchmark Hoek.unique vs Set
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