Socket
Book a DemoInstallSign in
Socket

performance-nodejs

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

performance-nodejs - npm Package Compare versions

Comparing version

to
0.0.5

5

.eslintrc.json
{
"extends": "airbnb/base"
"extends": "airbnb/base",
"rules": {
"strict": 0
}
}

45

index.js
'use strict';
/* eslint import/no-unresolved: 0 */
const v8 = require('v8');
const noop = function() {};
module.exports = performance;
const util = require('util');
function noop() {}
function performance(fn, interval) {
interval = interval || 100;
fn = fn || noop;
function getDelay(start, interval) {
const delta = process.hrtime(start);
const nanosec = delta[0] * 1e9 + delta[1];
return (nanosec / 1e6 | 0) - interval;
}
function getHeapStatistics() {
return v8.getHeapStatistics();
}
function get(arr, filter, defaultValue) {
let result;
arr.forEach(tmp => {
if (tmp && filter(tmp)) {
result = tmp;
}
});
return result || defaultValue;
}
function performance() {
/* eslint prefer-rest-params: 0 */
const args = Array.from(arguments);
const interval = get(args, util.isNumber, 100);
const fn = get(args, util.isFunction, noop);
let start = process.hrtime();

@@ -13,3 +36,3 @@ return setInterval(() => {

lag: getDelay(start, interval),
heap: getHeapStatistics()
heap: getHeapStatistics(),
});

@@ -21,10 +44,2 @@ start = process.hrtime();

function getDelay(start, interval) {
const delta = process.hrtime(start);
const nanosec = delta[0] * 1e9 + delta[1];
return (nanosec / 1e6 | 0) - interval;
}
function getHeapStatistics() {
return v8.getHeapStatistics();
}
module.exports = performance;
{
"name": "performance-nodejs",
"description": "get nodejs performance, eg: heap statistics, event loop delay",
"version": "0.0.4",
"version": "0.0.5",
"author": "Tree Xie <vicansocanbico@gmail.com>",

@@ -13,3 +13,3 @@ "keywords": [

"scripts": {
"test": "node ./node_modules/.bin/eslint ./lib/*.js && node ./node_modules/.bin/istanbul cover ./node_modules/.bin/_mocha ./test/*.js --"
"test": "node ./node_modules/.bin/eslint ./index.js && node ./node_modules/.bin/istanbul cover ./node_modules/.bin/_mocha ./test/*.js --"
},

@@ -23,7 +23,8 @@ "repository": {

},
"readme": "Get nodejs performance, eg: heap statistics, event loop delay",
"readmeFilename": "Readme.md",
"devDependencies": {
"eslint": "^2.5.1",
"eslint-config-airbnb": "^6.2.0",
"istanbul": "^0.4.2",
"eslint": "^2.9.0",
"eslint-config-airbnb": "^8.0.0",
"eslint-plugin-import": "^1.6.1",
"istanbul": "^0.4.3",
"mocha": "^2.4.5"

@@ -30,0 +31,0 @@ },

# performance-nodejs
[![Build Status](https://travis-ci.org/vicanso/performance-nodejs.svg?branch=master)](https://travis-ci.org/vicanso/performance-nodejs)
[![Build Status](https://travis-ci.org/vicanso/performance-nodejs.svg?style=flat-square)](https://travis-ci.org/vicanso/performance-nodejs)
[![Coverage Status](https://img.shields.io/coveralls/vicanso/performance-nodejs/master.svg?style=flat)](https://coveralls.io/r/vicanso/performance-nodejs?branch=master)
[![npm](http://img.shields.io/npm/v/performance-nodejs.svg?style=flat-square)](https://www.npmjs.org/package/performance-nodejs)
[![Github Releases](https://img.shields.io/npm/dm/performance-nodejs.svg?style=flat-square)](https://github.com/vicanso/performance-nodejs)
Get nodejs performance, eg: heap statistics, event loop delay

@@ -6,0 +10,0 @@

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.