Skip to content

Instantly share code, notes, and snippets.

@AdriVanHoudt
Created January 21, 2016 10:35

Revisions

  1. AdriVanHoudt created this gist Jan 21, 2016.
    21 changes: 21 additions & 0 deletions bench.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,21 @@
    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')