I have written some nodejs code and I am logging api call response timing. console.time() and Date.now() but I am not sure which one is better in performance and right to use.
Asked
Active
Viewed 906 times
1 Answers
1
Date.now() just returns the number of milliseconds from the linux Epoch, whereas
console.time()
is a shortcut to be used together with console.timeEnd()
, normally used for measuring the time that takes some operation, for example:
console.time()
doSomething()
console.timeEnd()
The output will be something like:
default: 7042.885ms
You can read more about it here:https://nodejs.org/api/console.html#console_console_time_label

Manuel Astudillo
- 186
- 1
- 12