performance-nodejs
Advanced tools
Comparing version
11
index.js
@@ -67,2 +67,12 @@ 'use strict'; | ||
function getMemoryUsage(unit) { | ||
const data = process.memoryUsage(); | ||
const keys = Object.keys(data); | ||
const result = {}; | ||
keys.forEach((key) => { | ||
result[key] = format(data[key], unit); | ||
}); | ||
return result; | ||
} | ||
function get(arr, filter, defaultValue) { | ||
@@ -119,2 +129,3 @@ let result; | ||
cpuUsage: getCpuUsage(cpuUsage, start), | ||
memoryUsage: getMemoryUsage(unitInfo), | ||
}); | ||
@@ -121,0 +132,0 @@ start = process.hrtime(); |
{ | ||
"name": "performance-nodejs", | ||
"description": "get nodejs performance, such as: heap statistics, event loop delay", | ||
"version": "1.0.5", | ||
"version": "1.0.6", | ||
"author": "Tree Xie <vicansocanbico@gmail.com>", | ||
@@ -34,2 +34,2 @@ "keywords": [ | ||
"license": "MIT" | ||
} | ||
} |
@@ -18,9 +18,9 @@ # performance-nodejs | ||
## Examples | ||
View the [./examples](examples) directory for working examples. | ||
View the [./examples](examples) directory for working examples. | ||
## Description | ||
The `performance()` function get node.js performance (include event loop, heap statistics and heap space statistics). | ||
The `performance()` function get node.js performance (include event loop, heap statistics and heap space statistics). | ||
@@ -39,3 +39,3 @@ * If node.js support v8.getHeapSpaceStatistics(), the heap space will be return. | ||
Returns: A reference to the timer. Useful for clearing the timer. | ||
Returns: A reference to the timer. Useful for clearing the timer. | ||
@@ -99,2 +99,8 @@ | ||
"total": 474737 | ||
}, | ||
"memoryUsage": { | ||
"rss": 20, | ||
"heapTotal": 5, | ||
"heapUsed": 4, | ||
"external": 0 | ||
} | ||
@@ -101,0 +107,0 @@ } |
8381
5.22%8
14.29%123
8.85%116
5.45%