@stdlib/time-tic

Return a high-resolution time.

Usage no npm install needed!

<script type="module">
  import stdlibTimeTic from 'https://cdn.skypack.dev/@stdlib/time-tic';
</script>

README

tic

NPM version Build Status Coverage Status

Return a high-resolution time.

Installation

npm install @stdlib/time-tic

Usage

var tic = require( '@stdlib/time-tic' );

tic()

Returns a high-resolution time.

var t = tic();
// returns [<number>,<number>]

The returned array has the following format: [seconds, nanoseconds].

Notes

Examples

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] );
}

Notice

This package is part of stdlib, a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more.

For more information on the project, filing bug reports and feature requests, and guidance on how to develop stdlib, see the main project repository.

Community

Chat


License

See LICENSE.

Copyright

Copyright © 2016-2022. The Stdlib Authors.