Skip to content
This repository was archived by the owner on Jan 12, 2026. It is now read-only.

Commit 16dc098

Browse files
--advanced -> --threads & remove from interactive cli
Resolves 57bb3a0#r1714034609
1 parent 57bb3a0 commit 16dc098

File tree

2 files changed

+19
-62
lines changed

2 files changed

+19
-62
lines changed

README.md

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,6 @@ The interactive CLI can guide you through the following steps:
2828
npx esperf
2929
```
3030

31-
## Advanced Usage
32-
33-
The interactive CLI will show more steps:
34-
35-
- Set scan speed
36-
37-
```sh
38-
npx esperf --advanced
39-
```
40-
4131
## License
4232

4333
MIT

src/main.ts

Lines changed: 19 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,27 @@ import {traverseFiles} from './stages/traverse-files.js';
1010
import {scanDependencies} from './stages/scan-dependencies.js';
1111
import {availableParallelism} from 'node:os';
1212

13-
let advanced = false;
13+
const maxThreads = availableParallelism();
14+
15+
const params: {
16+
threads: number;
17+
} = {
18+
threads: maxThreads * 0.5
19+
};
1420

1521
for (let i = 0; i < process.argv.length; ++i) {
16-
if (process.argv[i] === '--advanced') advanced = true;
22+
if (process.argv[i] === '--threads') {
23+
params.threads = Math.min(
24+
Math.max(Number(process.argv[i]) + 1, 1),
25+
maxThreads
26+
);
27+
}
1728
}
1829

19-
function getWantedThreads(scanSpeed: string): number {
20-
const threads = availableParallelism();
21-
switch (scanSpeed) {
22-
case 'slow':
23-
return threads * 0.25;
24-
case 'medium':
25-
return threads * 0.5;
26-
case 'fast':
27-
return threads * 0.75;
28-
case 'fastest':
29-
return threads;
30-
}
31-
return 1;
30+
if (params.threads) {
31+
if (params.threads > maxThreads) params.threads = maxThreads;
32+
} else {
33+
params.threads = maxThreads * 0.5;
3234
}
3335

3436
const availableManifests: Record<string, modReplacements.ManifestModule> = {
@@ -140,41 +142,7 @@ async function runModuleReplacements(): Promise<void> {
140142
cl.confirm({
141143
message: 'Automatically uninstall packages?',
142144
initialValue: false
143-
}),
144-
scanSpeed: () =>
145-
advanced
146-
? cl.select({
147-
message: 'Preferred scan speed',
148-
options: [
149-
{
150-
value: 'fastest',
151-
label: 'Fastest',
152-
hint: 'uses all the threads, pushes cpu to 100%'
153-
},
154-
{
155-
value: 'fast',
156-
label: 'Fast',
157-
hint: '75% of available threads'
158-
},
159-
{
160-
value: 'medium',
161-
label: 'Medium',
162-
hint: '50% of available threads'
163-
},
164-
{
165-
value: 'slow',
166-
label: 'Slow',
167-
hint: '25% of available threads'
168-
},
169-
{
170-
value: 'slowest',
171-
label: 'Slowest',
172-
hint: 'disables parallelism, 1 thread'
173-
}
174-
],
175-
initialValue: 'medium'
176-
})
177-
: Promise.resolve('medium')
145+
})
178146
},
179147
{
180148
onCancel: () => {
@@ -254,12 +222,11 @@ async function runModuleReplacements(): Promise<void> {
254222

255223
try {
256224
const files = await traverseFiles(options.filesDir);
257-
const threads = getWantedThreads(options.scanSpeed);
258225

259226
const scanFilesResult = await scanFiles(
260227
files,
261228
manifestReplacements,
262-
threads,
229+
params.threads,
263230
scanSpinner
264231
);
265232

0 commit comments

Comments
 (0)