Created
May 12, 2016 00:58
-
-
Save josephg/581b73e95c48f7daecca413c4ee06b04 to your computer and use it in GitHub Desktop.
Slow requires
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
var tree = require("terminal-tree"); | |
const loadingData = []; | |
var current = loadingData; | |
global.wr = (_require) => { | |
return (name) => { | |
const start = Date.now(); | |
const parent = current; | |
current = []; | |
const module = _require(name); | |
const time = Date.now() - start; | |
if (time > 20) { | |
parent.push(`${name} (${time}ms)`); | |
if (current.length > 0) parent.push(current); | |
} | |
current = parent; | |
return module; | |
} | |
}; | |
const _require = wr(require); | |
var keystone = _require('keystone'); | |
console.log(tree(loadingData, { | |
symbol: true, | |
highlight: true, | |
padding: 1 | |
})); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment