Created
April 9, 2014 16:23
-
-
Save jay3sh/10288621 to your computer and use it in GitHub Desktop.
Revisions
-
jay3sh created this gist
Apr 9, 2014 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,32 @@ var crypto = require('crypto'); function run(algo) { var hash = crypto.createHash(algo); hash.update('operation'); hash.update('1'); hash.update('A34'); hash.update('ABS'); return hash.digest('hex'); } function loop(algo) { var start = new Date().getTime(); for(var i=0; i<1000000; i++) { run(algo); } var end = new Date().getTime(); return end-start; } console.log('md5',run('md5').length, loop('md5')); console.log('sha1',run('sha1').length, loop('sha1')); console.log('sha256',run('sha256').length, loop('sha256')); /* Output of sample run (times in millisecond) md5 32 2810 sha1 40 2954 sha256 64 3311 */