Is console.time() safe in node.js?

前端 未结 3 1514
半阙折子戏
半阙折子戏 2021-02-01 06:40

I have a little snippet of node.js code in front of me that looks like this:

console.time(\"queryTime\");
doAsyncIOBoundThing(function(err, results) {
    consol         


        
3条回答
  •  鱼传尺愫
    2021-02-01 07:23

    Just use unique labels and it will be safe. That's why you use a label, to uniquely identify the start time.

    As long as you don't accidentally use a label twice everything will work exactly as intended. Also note that node has usually only one thread of execution.

提交回复
热议问题