Skip to content

Instantly share code, notes, and snippets.

@RyosukeCla
Last active December 19, 2019 07:35
Show Gist options
  • Save RyosukeCla/df94d74d5a32aee3a18397e52121ebbe to your computer and use it in GitHub Desktop.
Save RyosukeCla/df94d74d5a32aee3a18397e52121ebbe to your computer and use it in GitHub Desktop.
module require の performance を調べる
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