Skip to content

Instantly share code, notes, and snippets.

@rlidwka
Created December 2, 2012 16:43
Show Gist options
  • Save rlidwka/4189717 to your computer and use it in GitHub Desktop.
Save rlidwka/4189717 to your computer and use it in GitHub Desktop.
var crypto = require('crypto');
var crc32 = require('crc').crc32;
var x = 1;
while(1){
var string = '';
for (var j=0; j<x; j++) {
string += String(Math.random());
}
var iter = 1000000/Math.sqrt(x);
var start = Date.now();
for (var i=0; i<iter; i++) {
crypto.createHash('md5').update(string).digest('hex');
}
var fin1 = Date.now();
for (var i=0; i<iter; i++) {
crc32(string);
}
console.log(string.length, (fin1-start)/iter*1000000, (Date.now()-fin1)/iter*1000000);
x*=1.5;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment