Quantcast
Channel: Active questions tagged visual-studio-code - Stack Overflow
Viewing all articles
Browse latest Browse all 97371

inconsistant return value of console.timeEnd()

$
0
0

I have following snippet taken from nodejs docs,

console.time('100-elements');
for (let i = 0; i < 100; i++) { }
console.timeEnd('100-elements');
// prints 100-elements: 225.438ms

When I run the above snippet locally in VS-Code (in node environment), the console logs twice, this is basically looged by console.timeEnd() something like,

100-elements: 0.009033203125ms
100-elements: 0.285ms

Also, when I do console.time('foo') nothing is logged, unless I do console.timeEnd('foo') which in turn logs two times.

What can be the reason for this behaviour?

Looking into nodejs docs and MDN docs also I didn't find any mention of console.time() logging any time. More importantly,

What does the time returned by console.timeEnd() indicate ?

UPDATE: When I run the script from the terminal (macOS's default terminal) it prints output as expected; however the above behaviour was observed when debugging using VS-Code.

Also, to make myself more clear, the dual logs are printed via console.timeEnd()

Node version is: v10.16.

here's my launch.json

{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "node",
            "request": "launch",
            "name": "foo",
            "program": "${workspaceFolder}/index.js"
        }
    ]
}

Viewing all articles
Browse latest Browse all 97371

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>