Skip to content

Instantly share code, notes, and snippets.

@danielo515
Last active December 14, 2016 16:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danielo515/c10b7cf8725020a9ffbd83666021b55a to your computer and use it in GitHub Desktop.
Save danielo515/c10b7cf8725020a9ffbd83666021b55a to your computer and use it in GitHub Desktop.
A small benchmark to check if Crypto JS is able to generate GUUID
const CryptoJS = require("crypto-js");
const _ = require('lodash');
let i = 5000;
const keys = [];
console.time('Generating keys');
while(--i)
keys.push(CryptoJS.lib.WordArray.random(128 / 8).toString(CryptoJS.sha256));
i = 5000
while(--i)
keys.push(CryptoJS.lib.WordArray.random(128 / 8).toString(CryptoJS.sha256));
console.timeEnd('Generating keys');
console.log(keys)
console.time('Checking dups');
const dups = _.filter(keys, (value, index, iteratee) => _.includes(iteratee, value, index + 1))
console.timeEnd('Checking dups');
console.log(dups)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment