Return a high-resolution time.
var tic = require( '@stdlib/time/tic' );Returns a high-resolution time.
var t = tic();
// returns [<number>,<number>]The returned array has the following format: [seconds, nanoseconds].
- In browser environments, the implementation uses the
performance.nowAPI. If theperformance-nowAPI is unavailable, the implementation falls back to theDateobject. - In non-browser environments, the implementation uses
process.hrtime.
var tic = require( '@stdlib/time/tic' );
var toc = require( '@stdlib/time/toc' );
var start = tic();
setTimeout( onTimeout, 2000 );
function onTimeout() {
var elapsed = toc( start );
console.log( 'Elapsed: %d seconds and %d nanoseconds', elapsed[0], elapsed[1] );
}@stdlib/time/toc: return a high-resolution time difference.