DEV Community

misterpah
misterpah

Posted on

Printing output is slowing down your API

I got bored and did a quick experiment. Nothing fancy, just a simple Nodejs API that stores your name and age into MySQL database.
The script is shown below. Notice that there's a console.log that prints the SQL statement before the query.

nodejs store name and age into mysql

Using a simple bash command to loop, query the API and take the time elapsed; there's a 1-second difference between code with and without console.log.bash script to query API

console.log is useful for debugging, but make sure you remove them in production :)

Discussion (0)