Created
August 13, 2014 08:15
-
-
Save n3dst4/317171514441b834d1ea to your computer and use it in GitHub Desktop.
Time how long all your require()s take
This file contains 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 characters
/* | |
* requireTime.js | |
* | |
* require()s every thing in your node_modules and tells you how long each one | |
* took. | |
* | |
* USAGE: | |
* $ cd your_project_folder | |
* $ node loadTest.js | |
* | |
* Based on this comment: | |
* https://github.com/gulpjs/gulp/issues/282#issuecomment-35482108 | |
*/ | |
var modules = require('fs').readdirSync('node_modules').filter( | |
function (name) { return name !== '.bin';} | |
); | |
console.time("+++TOTAL"); | |
modules.forEach(function (m) { | |
console.time(m); | |
try { | |
require(m); | |
console.timeEnd(m); | |
} | |
catch (e) { | |
console.warn(m + ": " + e); | |
} | |
}); | |
console.timeEnd("+++TOTAL"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment