Jaguard / time-require

Displays the execution time for Node.js modules loading by hooking require() calls
MIT License
253 stars 20 forks source link

when a filename is listed more than once #2

Open dylang opened 10 years ago

dylang commented 10 years ago

if this happens...

a.js  75 ms
b.js  622 ms
a.js  43 ms 

Does that mean the two a.js must be different versions and therefor are not the same file on the disk?

If I make sure they are the same version should that eliminate of the requires because it should be cached and take less than 1%?

cyparu commented 10 years ago

All modules are cached by default by Node.js, based on their resolved filename but depending on the caller module location. See the details here http://nodejs.org/api/modules.html#modules_caching.

The requireHook just simply override Module._load so basically will be invoked AFAIK before the cache ... It seams that even the cashed require() calls will involve some penalty.