Skip to content

Commit 3920648

Browse files
perf: use availableParallelism instead of exec (#123)
* fix: use `availableParallelism` instead of `exec` * test: remove unused test * test: fix failing cpu test --------- Co-authored-by: Vladimir Sheremet <[email protected]>
1 parent 6422505 commit 3920648

File tree

4 files changed

+3
-155
lines changed

4 files changed

+3
-155
lines changed

src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { inspect, types } from 'node:util'
1111
import assert from 'node:assert'
1212
import { performance } from 'node:perf_hooks'
1313
import { readFileSync } from 'node:fs'
14-
import { amount as physicalCpuCount } from './physicalCpuCount'
14+
import { availableParallelism } from 'node:os'
1515
import {
1616
type ReadyMessage,
1717
type RequestMessage,
@@ -50,7 +50,7 @@ declare global {
5050
}
5151
}
5252

53-
const cpuCount: number = physicalCpuCount
53+
const cpuCount: number = availableParallelism()
5454

5555
interface AbortSignalEventTargetAddOptions {
5656
once: boolean

src/physicalCpuCount.ts

Lines changed: 0 additions & 52 deletions
This file was deleted.

test/cpu-count.test.ts

Lines changed: 0 additions & 100 deletions
This file was deleted.

test/options.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ vi.mock(import('node:os'), async (importOriginal) => {
5151
const original = await importOriginal()
5252
return {
5353
...original,
54-
default: { ...original.default, cpus: () => Array(cpuCount) },
54+
availableParallelism: () => cpuCount,
5555
}
5656
})
5757

0 commit comments

Comments
 (0)