Files
node/test/parallel/test-resource-usage.js
T
vmarchaud 19f9281743 process: expose uv_rusage on process.resourcesUsage()
As discussed in https://github.com/nodejs/diagnostics/issues/161,
the core should expose important metrics about the runtime, this PR's
goal is to let user get the number of io request made, and lower level
mertrics like the page faults and context switches.

PR-URL: https://github.com/nodejs/node/pull/28018
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2019-07-02 11:46:57 +02:00

28 lines
580 B
JavaScript

'use strict';
require('../common');
const assert = require('assert');
const rusage = process.resourceUsage();
[
'userCPUTime',
'systemCPUTime',
'maxRSS',
'sharedMemorySize',
'unsharedDataSize',
'unsharedStackSize',
'minorPageFault',
'majorPageFault',
'swappedOut',
'fsRead',
'fsWrite',
'ipcSent',
'ipcReceived',
'signalsCount',
'voluntaryContextSwitches',
'involuntaryContextSwitches'
].forEach((n) => {
assert.strictEqual(typeof rusage[n], 'number', `${n} should be a number`);
assert(rusage[n] >= 0, `${n} should be above or equal 0`);
});