mirror of
https://github.com/nodejs/node.git
synced 2025-05-07 15:35:41 +00:00

This commit adds an assertion checking the exact field names returned by process.resourceUsage(). This ensures that no new fields accidentally slip into the returned object in the future. PR-URL: https://github.com/nodejs/node/pull/28498 Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
31 lines
671 B
JavaScript
31 lines
671 B
JavaScript
'use strict';
|
|
require('../common');
|
|
const assert = require('assert');
|
|
|
|
const rusage = process.resourceUsage();
|
|
const fields = [
|
|
'userCPUTime',
|
|
'systemCPUTime',
|
|
'maxRSS',
|
|
'sharedMemorySize',
|
|
'unsharedDataSize',
|
|
'unsharedStackSize',
|
|
'minorPageFault',
|
|
'majorPageFault',
|
|
'swappedOut',
|
|
'fsRead',
|
|
'fsWrite',
|
|
'ipcSent',
|
|
'ipcReceived',
|
|
'signalsCount',
|
|
'voluntaryContextSwitches',
|
|
'involuntaryContextSwitches'
|
|
];
|
|
|
|
assert.deepStrictEqual(Object.keys(rusage).sort(), fields.sort());
|
|
|
|
fields.forEach((n) => {
|
|
assert.strictEqual(typeof rusage[n], 'number', `${n} should be a number`);
|
|
assert(rusage[n] >= 0, `${n} should be above or equal 0`);
|
|
});
|