Node.js console.log performance

前端 未结 4 542
无人及你
无人及你 2021-02-01 04:15

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 import

4条回答
  •  终归单人心
    2021-02-01 04:53

    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.

提交回复
热议问题