PR-URL: https://github.com/nodejs/node/pull/58210 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
31 lines
898 B
JavaScript
31 lines
898 B
JavaScript
// Flags: --expose-internals --no-warnings --allow-natives-syntax
|
|
'use strict';
|
|
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
const {
|
|
totalmem,
|
|
freemem,
|
|
availableParallelism,
|
|
} = require('os');
|
|
|
|
const { internalBinding } = require('internal/test/binding');
|
|
|
|
function testFastOs() {
|
|
assert.strictEqual(typeof totalmem(), 'number');
|
|
assert.strictEqual(typeof freemem(), 'number');
|
|
assert.strictEqual(typeof availableParallelism(), 'number');
|
|
}
|
|
|
|
eval('%PrepareFunctionForOptimization(testFastOs)');
|
|
testFastOs();
|
|
eval('%OptimizeFunctionOnNextCall(testFastOs)');
|
|
testFastOs();
|
|
|
|
if (common.isDebug) {
|
|
const { getV8FastApiCallCount } = internalBinding('debug');
|
|
assert.strictEqual(getV8FastApiCallCount('os.totalmem'), 1);
|
|
assert.strictEqual(getV8FastApiCallCount('os.freemem'), 1);
|
|
assert.strictEqual(getV8FastApiCallCount('os.availableParallelism'), 1);
|
|
}
|