Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

window.performance.now() equivalent in nodejs?

I think the question is straight forward.

I'm looking for something that's similar to window.performance.now() in nodejs V8 engine.

Right now I'm just using:-

var now = Date.now(); //do some processing.. console.log("time elapsed:", Date.now() - now); 

But, I read that window.performance.now() is lot more accurate than using the date because of the what's defined here.

like image 708
shriek Avatar asked Apr 11 '14 04:04

shriek


People also ask

What is performance now in js?

The performance. now() method returns a DOMHighResTimeStamp , measured in milliseconds. Note: This feature is available in Web Workers. The returned value represents the time elapsed since the time origin.


1 Answers

Node v8.5.0 has added Performance Timing API, which includes the performance#now(), e.g.

const {   performance } = require('perf_hooks');  console.log('performance', performance.now()); 
like image 188
Gajus Avatar answered Sep 25 '22 13:09

Gajus