@jkroso/now
v0.1.0
Published
get the highest resolution timestamp available x-browser
Downloads
9
Maintainers
Readme
now
get the highest resolution timestamp available x-browser
Getting Started
$ {package mananger} install jkroso/now
then in your app:
var now = require('now')
API
now()
will return a timestamp relative to some arbitrary time in the past in milliseconds (ms). In older browsers that time happens to be the unix Epoch so is a lot bigger than it would be in a modern browser which will give you a time relative to page load.
now() // => 15.333000003010966
example
one possible use case is benchmarking
var start = now()
while (now() - start < 10) continue;
console.log('bench took %dms', start - now())
// => bench took 10ms
Running the example
$ npm install
$ make
Then open your browser to the ./example.html
.
Note: these commands don't work on windows.