mock-cpu-length
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

mock-cpu-length

Mock os.cpus().length in CI env(!!process.env.CI === true). It often gets wrong CPU core length when using os.cpus().length in some CI environments due to containerized technology such as CPU share. It would affect how many child processes should be forked/spawned and cause huge performance issue in Node.js.

Usage

Notice: This package only has impact in CI.

const os = require('os');
const { mockCPULength, resetCPULength } = require('mock-cpu-length');

process.env.CI = true;

mockCPULength(2);
console.log(os.cpus().length); // print `2`

mockCPULength(3);
console.log(os.cpus().length); // print `3`

resetCPULength();
console.log(os.cpus().length); // print the actual CPU cores number

License

MIT

Readme

Keywords

none

Package Sidebar

Install

npm i mock-cpu-length

Weekly Downloads

1

Version

1.0.2

License

none

Unpacked Size

3.43 kB

Total Files

4

Last publish

Collaborators

  • luckydrq