Socket
Socket
Sign inDemoInstall

performance-now

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

performance-now - npm Package Compare versions

Comparing version 1.0.2 to 2.0.0

8

lib/performance-now.js
// Generated by CoffeeScript 1.12.2
(function() {
var getNanoSeconds, hrtime, loadTime;
var getNanoSeconds, hrtime, loadTime, moduleLoadTime, nodeLoadTime, upTime;

@@ -11,3 +11,3 @@ if ((typeof performance !== "undefined" && performance !== null) && performance.now) {

module.exports = function() {
return (getNanoSeconds() - loadTime) / 1e6;
return (getNanoSeconds() - nodeLoadTime) / 1e6;
};

@@ -20,3 +20,5 @@ hrtime = process.hrtime;

};
loadTime = getNanoSeconds();
moduleLoadTime = getNanoSeconds();
upTime = process.uptime() * 1e9;
nodeLoadTime = moduleLoadTime - upTime;
} else if (Date.now) {

@@ -23,0 +25,0 @@ module.exports = function() {

@@ -5,3 +5,3 @@ {

"keywords": [],
"version": "1.0.2",
"version": "2.0.0",
"author": "Braveg1rl <braveg1rl@outlook.com>",

@@ -8,0 +8,0 @@ "license": "MIT",

@@ -5,8 +5,12 @@ # performance-now [![Build Status](https://travis-ci.org/braveg1rl/performance-now.png?branch=master)](https://travis-ci.org/braveg1rl/performance-now) [![Dependency Status](https://david-dm.org/braveg1rl/performance-now.png)](https://david-dm.org/braveg1rl/performance-now)

Modern browsers have a `window.performance` object with - among others - a `now` method which gives time in miliseconds, but with sub-milisecond precision. This module offers the same function based on the Node.js native `process.hrtime` function.
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.
According to the [High Resolution Time specification](http://www.w3.org/TR/hr-time/), the number of miliseconds reported by `performance.now` should be relative to the value of `performance.timing.navigationStart`. For this module, it's relative to when the time when this module got loaded. Right after requiring this module for the first time, the reported time is expected to have a near-zero value.
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

@@ -18,3 +22,3 @@

var end = now()
console.log(start.toFixed(3)) // ~ 0.05 on my system
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

@@ -25,9 +29,5 @@ ```

## Credits
The initial structure of this module was generated by [Jumpstart](https://github.com/braveg1rl/jumpstart), using the [Jumpstart Black Coffee](https://github.com/braveg1rl/jumpstart-black-coffee) template.
## License
performance-now is released under the [MIT License](http://opensource.org/licenses/MIT).
Copyright (c) 2013 Braveg1rl
Copyright (c) 2017 Braveg1rl

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc