Skip to content

Commit b2f3b4e

Browse files
committed
Add number of threads to progress output
1 parent 2f8ed4d commit b2f3b4e

File tree

6 files changed

+29
-27
lines changed

6 files changed

+29
-27
lines changed

src/Psalm/Internal/Analyzer/ProjectAnalyzer.php

+8-8
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,7 @@ public function check(string $base_dir, bool $is_diff = false): void
462462
}
463463

464464
$this->progress->write($this->generatePHPVersionMessage());
465-
$this->progress->startPhase(Phase::SCAN);
465+
$this->progress->startPhase(Phase::SCAN, $this->scanThreads);
466466

467467
$diff_no_files = false;
468468

@@ -520,7 +520,7 @@ public function check(string $base_dir, bool $is_diff = false): void
520520
$this->config->eventDispatcher->dispatchAfterCodebasePopulated($event);
521521
}
522522

523-
$this->progress->startPhase(Phase::ANALYSIS);
523+
$this->progress->startPhase(Phase::ANALYSIS, $this->threads);
524524

525525
$this->codebase->analyzer->analyzeFiles(
526526
$this,
@@ -876,15 +876,15 @@ public function checkDir(string $dir_name): void
876876
$this->checkDirWithConfig($dir_name, $this->config, true);
877877

878878
$this->progress->write($this->generatePHPVersionMessage());
879-
$this->progress->startPhase(Phase::SCAN);
879+
$this->progress->startPhase(Phase::SCAN, $this->scanThreads);
880880

881881
$this->config->initializePlugins($this);
882882

883883
$this->codebase->scanFiles($this->scanThreads);
884884

885885
$this->config->visitStubFiles($this->codebase, $this->progress);
886886

887-
$this->progress->startPhase(Phase::ANALYSIS);
887+
$this->progress->startPhase(Phase::ANALYSIS, $this->threads);
888888

889889
$this->codebase->analyzer->analyzeFiles(
890890
$this,
@@ -976,15 +976,15 @@ public function checkFile(string $file_path): void
976976
$this->file_reference_provider->loadReferenceCache();
977977

978978
$this->progress->write($this->generatePHPVersionMessage());
979-
$this->progress->startPhase(Phase::SCAN);
979+
$this->progress->startPhase(Phase::SCAN, $this->scanThreads);
980980

981981
$this->config->initializePlugins($this);
982982

983983
$this->codebase->scanFiles($this->scanThreads);
984984

985985
$this->config->visitStubFiles($this->codebase, $this->progress);
986986

987-
$this->progress->startPhase(Phase::ANALYSIS);
987+
$this->progress->startPhase(Phase::ANALYSIS, $this->threads);
988988

989989
$this->codebase->analyzer->analyzeFiles(
990990
$this,
@@ -1000,7 +1000,7 @@ public function checkFile(string $file_path): void
10001000
public function checkPaths(array $paths_to_check): void
10011001
{
10021002
$this->progress->write($this->generatePHPVersionMessage());
1003-
$this->progress->startPhase(Phase::SCAN);
1003+
$this->progress->startPhase(Phase::SCAN, $this->scanThreads);
10041004

10051005
$this->config->visitPreloadedStubFiles($this->codebase, $this->progress);
10061006
$this->visitAutoloadFiles();
@@ -1032,7 +1032,7 @@ public function checkPaths(array $paths_to_check): void
10321032

10331033
$this->config->eventDispatcher->dispatchAfterCodebasePopulated($event);
10341034

1035-
$this->progress->startPhase(Phase::ANALYSIS);
1035+
$this->progress->startPhase(Phase::ANALYSIS, $this->threads);
10361036

10371037
$this->codebase->analyzer->analyzeFiles(
10381038
$this,

src/Psalm/Internal/LanguageServer/Progress.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public function debug(string $message): void
3232
}
3333

3434
#[Override]
35-
public function startPhase(Phase $phase): void
35+
public function startPhase(Phase $phase, int $threads = 1): void
3636
{
3737
}
3838

src/Psalm/Progress/DebugProgress.php

+9-8
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,17 @@ public function debug(string $message): void
2525
}
2626

2727
#[Override]
28-
public function startPhase(Phase $phase): void
28+
public function startPhase(Phase $phase, int $threads = 1): void
2929
{
30+
$threads = $threads === 1 ? '' : " ($threads threads)";
3031
$this->write(match ($phase) {
31-
Phase::SCAN => "\nScanning files...\n\n",
32-
Phase::ANALYSIS => "\nAnalyzing files...\n",
33-
Phase::ALTERING => "\nUpdating files...\n",
34-
Phase::TAINT_GRAPH_RESOLUTION => "\nResolving taint graph...\n",
35-
Phase::JIT_COMPILATION => "\nJIT compilation in progress...\n",
36-
Phase::PRELOADING => "\nPreloading in progress...\n",
37-
Phase::MERGING_THREAD_RESULTS => "\nMerging thread results...\n",
32+
Phase::SCAN => "\nScanning files$threads...\n\n",
33+
Phase::ANALYSIS => "\nAnalyzing files$threads...\n",
34+
Phase::ALTERING => "\nUpdating files$threads...\n",
35+
Phase::TAINT_GRAPH_RESOLUTION => "\nResolving taint graph$threads...\n",
36+
Phase::JIT_COMPILATION => "\nJIT compilation in progress$threads...\n",
37+
Phase::PRELOADING => "\nPreloading in progress$threads...\n",
38+
Phase::MERGING_THREAD_RESULTS => "\nMerging thread results$threads...\n",
3839
});
3940
}
4041

src/Psalm/Progress/LongProgress.php

+9-8
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,18 @@ public function debug(string $message): void
4242
}
4343

4444
#[Override]
45-
public function startPhase(Phase $phase): void
45+
public function startPhase(Phase $phase, int $threads = 1): void
4646
{
47+
$threads = $threads === 1 ? '' : " ($threads threads)";
4748
$this->reportPhaseDuration($phase);
4849
$this->write(match ($phase) {
49-
Phase::SCAN => "\nScanning files...\n\n",
50-
Phase::ANALYSIS => "\nAnalyzing files...\n\n",
51-
Phase::ALTERING => "\nUpdating files...\n",
52-
Phase::TAINT_GRAPH_RESOLUTION => "\n\nResolving taint graph...\n\n",
53-
Phase::JIT_COMPILATION => "JIT compilation in progress...\n\n",
54-
Phase::PRELOADING => "Preloading in progress...\n\n",
55-
Phase::MERGING_THREAD_RESULTS => "\nMerging thread results...\n\n",
50+
Phase::SCAN => "\nScanning files$threads...\n\n",
51+
Phase::ANALYSIS => "\nAnalyzing files$threads...\n\n",
52+
Phase::ALTERING => "\nUpdating files$threads...\n",
53+
Phase::TAINT_GRAPH_RESOLUTION => "\n\nResolving taint graph$threads...\n\n",
54+
Phase::JIT_COMPILATION => "JIT compilation in progress$threads...\n\n",
55+
Phase::PRELOADING => "Preloading in progress$threads...\n\n",
56+
Phase::MERGING_THREAD_RESULTS => "\nMerging thread results$threads...\n\n",
5657
});
5758
$this->fixed_size = $phase === Phase::ANALYSIS
5859
|| $phase === Phase::ALTERING

src/Psalm/Progress/Progress.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public function setErrorReporting(): void
2525
abstract public function debug(string $message): void;
2626

2727

28-
abstract public function startPhase(Phase $phase): void;
28+
abstract public function startPhase(Phase $phase, int $threads = 1): void;
2929

3030
abstract public function expand(int $number_of_tasks): void;
3131

src/Psalm/Progress/VoidProgress.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public function debug(string $message): void
1414
}
1515

1616
#[Override]
17-
public function startPhase(Phase $phase): void
17+
public function startPhase(Phase $phase, int $threads = 1): void
1818
{
1919
}
2020

0 commit comments

Comments
 (0)