PK v[�\�%ٸ� � README.mdnu �[��� # performance-now [](https://travis-ci.org/braveg1rl/performance-now) [](https://david-dm.org/braveg1rl/performance-now)
Implements a function similar to `performance.now` (based on `process.hrtime`).
Modern browsers have a `window.performance` object with - among others - a `now` method which gives time in milliseconds, but with sub-millisecond precision. This module offers the same function based on the Node.js native `process.hrtime` function.
Using `process.hrtime` means that the reported time will be monotonically increasing, and not subject to clock-drift.
According to the [High Resolution Time specification](http://www.w3.org/TR/hr-time/), the number of milliseconds reported by `performance.now` should be relative to the value of `performance.timing.navigationStart`.
In the current version of the module (2.0) the reported time is relative to the time the current Node process has started (inferred from `process.uptime()`).
Version 1.0 reported a different time. The reported time was relative to the time the module was loaded (i.e. the time it was first `require`d). If you need this functionality, version 1.0 is still available on NPM.
## Example usage
```javascript
var now = require("performance-now")
var start = now()
var end = now()
console.log(start.toFixed(3)) // the number of milliseconds the current node process is running
console.log((start-end).toFixed(3)) // ~ 0.002 on my system
```
Running the now function two times right after each other yields a time difference of a few microseconds. Given this overhead, I think it's best to assume that the precision of intervals computed with this method is not higher than 10 microseconds, if you don't know the exact overhead on your own system.
## License
performance-now is released under the [MIT License](http://opensource.org/licenses/MIT).
Copyright (c) 2017 Braveg1rl
PK w[�\�� license.txtnu �[��� Copyright (c) 2013 Braveg1rl
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.PK x[�\��f�� � .tm_propertiesnu �[��� excludeDirectories = "{.git,node_modules}"
excludeInFolderSearch = "{excludeDirectories,lib}"
includeFiles = "{.gitignore,.npmignore,.travis.yml}"
[ attr.untitled ]
fileType = 'source.coffee'PK x[�\��'� � package.jsonnu �[��� {
"_from": "performance-now@^2.1.0",
"_id": "performance-now@2.1.0",
"_inBundle": false,
"_integrity": "sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns=",
"_location": "/performance-now",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "performance-now@^2.1.0",
"name": "performance-now",
"escapedName": "performance-now",
"rawSpec": "^2.1.0",
"saveSpec": null,
"fetchSpec": "^2.1.0"
},
"_requiredBy": [
"/request"
],
"_resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz",
"_shasum": "6309f4e0e5fa913ec1c69307ae364b4b377c9e7b",
"_spec": "performance-now@^2.1.0",
"_where": "/Users/zkat/Documents/code/work/npm/node_modules/request",
"author": {
"name": "Braveg1rl",
"email": "braveg1rl@outlook.com"
},
"bugs": {
"url": "https://github.com/braveg1rl/performance-now/issues"
},
"bundleDependencies": false,
"dependencies": {},
"deprecated": false,
"description": "Implements performance.now (based on process.hrtime).",
"devDependencies": {
"bluebird": "^3.4.7",
"call-delayed": "^1.0.0",
"chai": "^3.5.0",
"chai-increasing": "^1.2.0",
"coffee-script": "~1.12.2",
"mocha": "~3.2.0",
"pre-commit": "^1.2.2"
},
"homepage": "https://github.com/braveg1rl/performance-now",
"keywords": [],
"license": "MIT",
"main": "lib/performance-now.js",
"name": "performance-now",
"optionalDependencies": {},
"private": false,
"repository": {
"type": "git",
"url": "git://github.com/braveg1rl/performance-now.git"
},
"scripts": {
"build": "mkdir -p lib && rm -rf lib/* && node_modules/.bin/coffee --compile -m --output lib/ src/",
"prepublish": "npm test",
"pretest": "npm run build",
"test": "mocha",
"watch": "coffee --watch --compile --output lib/ src/"
},
"typings": "src/index.d.ts",
"version": "2.1.0"
}
PK x[�\��gA A .travis.ymlnu �[��� language: node_js
node_js:
- "node"
- "6"
- "4"
- "0.12"
PK y[�\M��) ) src/performance-now.coffeenu �[��� if performance? and performance.now
module.exports = -> performance.now()
else if process? and process.hrtime
module.exports = -> (getNanoSeconds() - nodeLoadTime) / 1e6
hrtime = process.hrtime
getNanoSeconds = ->
hr = hrtime()
hr[0] * 1e9 + hr[1]
moduleLoadTime = getNanoSeconds()
upTime = process.uptime() * 1e9
nodeLoadTime = moduleLoadTime - upTime
else if Date.now
module.exports = -> Date.now() - loadTime
loadTime = Date.now()
else
module.exports = -> new Date().getTime() - loadTime
loadTime = new Date().getTime()
PK y[�\�tp�� � src/index.d.tsnu �[��� // This file describes the package to typescript.
/**
* Returns the number of milliseconds since the page was loaded (if browser)
* or the node process was started.
*/
declare function now(): number;
export = now;
PK z[�\�H�
.npmignorenu �[��� .DS_StorePK z[�\��l% % lib/performance-now.jsnu �[��� // Generated by CoffeeScript 1.12.2
(function() {
var getNanoSeconds, hrtime, loadTime, moduleLoadTime, nodeLoadTime, upTime;
if ((typeof performance !== "undefined" && performance !== null) && performance.now) {
module.exports = function() {
return performance.now();
};
} else if ((typeof process !== "undefined" && process !== null) && process.hrtime) {
module.exports = function() {
return (getNanoSeconds() - nodeLoadTime) / 1e6;
};
hrtime = process.hrtime;
getNanoSeconds = function() {
var hr;
hr = hrtime();
return hr[0] * 1e9 + hr[1];
};
moduleLoadTime = getNanoSeconds();
upTime = process.uptime() * 1e9;
nodeLoadTime = moduleLoadTime - upTime;
} else if (Date.now) {
module.exports = function() {
return Date.now() - loadTime;
};
loadTime = Date.now();
} else {
module.exports = function() {
return new Date().getTime() - loadTime;
};
loadTime = new Date().getTime();
}
}).call(this);
//# sourceMappingURL=performance-now.js.map
PK {[�\se�� � lib/performance-now.js.mapnu �[��� {
"version": 3,
"file": "performance-now.js",
"sourceRoot": "..",
"sources": [
"src/performance-now.coffee"
],
"names": [],
"mappings": ";AAAA;AAAA,MAAA;;EAAA,IAAG,4DAAA,IAAiB,WAAW,CAAC,GAAhC;IACE,MAAM,CAAC,OAAP,GAAiB,SAAA;aAAG,WAAW,CAAC,GAAZ,CAAA;IAAH,EADnB;GAAA,MAEK,IAAG,oDAAA,IAAa,OAAO,CAAC,MAAxB;IACH,MAAM,CAAC,OAAP,GAAiB,SAAA;aAAG,CAAC,cAAA,CAAA,CAAA,GAAmB,YAApB,CAAA,GAAoC;IAAvC;IACjB,MAAA,GAAS,OAAO,CAAC;IACjB,cAAA,GAAiB,SAAA;AACf,UAAA;MAAA,EAAA,GAAK,MAAA,CAAA;aACL,EAAG,CAAA,CAAA,CAAH,GAAQ,GAAR,GAAc,EAAG,CAAA,CAAA;IAFF;IAGjB,cAAA,GAAiB,cAAA,CAAA;IACjB,MAAA,GAAS,OAAO,CAAC,MAAR,CAAA,CAAA,GAAmB;IAC5B,YAAA,GAAe,cAAA,GAAiB,OAR7B;GAAA,MASA,IAAG,IAAI,CAAC,GAAR;IACH,MAAM,CAAC,OAAP,GAAiB,SAAA;aAAG,IAAI,CAAC,GAAL,CAAA,CAAA,GAAa;IAAhB;IACjB,QAAA,GAAW,IAAI,CAAC,GAAL,CAAA,EAFR;GAAA,MAAA;IAIH,MAAM,CAAC,OAAP,GAAiB,SAAA;aAAO,IAAA,IAAA,CAAA,CAAM,CAAC,OAAP,CAAA,CAAJ,GAAuB;IAA1B;IACjB,QAAA,GAAe,IAAA,IAAA,CAAA,CAAM,CAAC,OAAP,CAAA,EALZ;;AAXL"
}PK v[�\�%ٸ� � README.mdnu �[��� PK w[�\�� license.txtnu �[��� PK x[�\��f�� � u .tm_propertiesnu �[��� PK x[�\��'� � t
package.jsonnu �[��� PK x[�\��gA A 0 .travis.ymlnu �[��� PK y[�\M��) ) � src/performance-now.coffeenu �[��� PK y[�\�tp�� � src/index.d.tsnu �[��� PK z[�\�H�
7 .npmignorenu �[��� PK z[�\��l% % z lib/performance-now.jsnu �[��� PK {[�\se�� � � lib/performance-now.js.mapnu �[��� PK
�!