We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PoC using a preload script:
// logrequires.js 'use strict'; var js = require.extensions['.js']; require.extensions['.js'] = (...args) => { console.log('loading module', args[0].filename); return js(...args); };
node -r ./logrequires.js myscript.js
The text was updated successfully, but these errors were encountered:
basic implementation done: ndbg trace-requires myscript.js to test.
ndbg trace-requires myscript.js
Sorry, something went wrong.
It could be interesting to hook the performance of each module at the same time no ? (With perf_hooks).
const { performance, PerformanceObserver } = require("perf_hooks"); const mod = require("module"); // Monkey patch the require function mod.Module.prototype.require = performance.timerify(mod.Module.prototype.require); require = performance.timerify(require); // Activate the observer const obs = new PerformanceObserver((list) => { let fullRequireTime = 0; const entries = list.getEntries(); entries.forEach((entry) => { console.log(`module '${entry[0]}' load in %s ms`, entry.duration); fullRequireTime += entry.duration; }); console.log(`Average require time: ${fullRequireTime / entries.length} ms`); console.log(`Complete load time ${fullRequireTime} ms`); obs.disconnect(); }); obs.observe({ entryTypes: ["function"], buffered: true });
No branches or pull requests
PoC using a preload script:
node -r ./logrequires.js myscript.js
The text was updated successfully, but these errors were encountered: