Last active
December 19, 2019 07:35
-
-
Save RyosukeCla/df94d74d5a32aee3a18397e52121ebbe to your computer and use it in GitHub Desktop.
module require の performance を調べる
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 characters
const Module = require('module'); | |
const originalRequire = Module.prototype.require; | |
const performance = require('perf_hooks').performance | |
Module.prototype.require = function(){ | |
const now = performance.now() | |
const res = originalRequire.apply(this, arguments) | |
console.log({ filename: this.filename, time: performance.now() - now }) | |
return res | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment