If your Node.js code is littered with console.log statements are you inviting performance issues? Is it worth debug/production toggling this on/off? I realized logging is important to prod in general - but I'm generally curious if the console output has a performance hit?
In Chrome it definitely seems to degrade performance if the console is open.
It greatly effects performance. I just did a test with console. log with 60,000 keys in my GAMES object. Then, simply did a for in to check if a property exists while console logging the GAMES object before checking.
console. log by itself doesn't really impact performance in a way that you'll notice unless you bind it to a scroll / resize handler. These get called alot and if your browser has to send text to the console like 30/60x a second it can get ugly.
console.log calls in nodejs are synchronous(!) and block the event loop. I just experienced that when I logged the results from executing (asynchronous) sql queries with pg. Logging only 20 items and their (few) properties decreased the performance from 3ms to 300ms on my local machine.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With