Skip to content

Conversation

@staabm
Copy link
Contributor

@staabm staabm commented Nov 22, 2025

requires theseer/tokenizer#38

before this PR (using PHPUnit 12.4.4)

➜  slow-coverage-xml1 git:(main) ✗ hyperfine 'php coverage-xml.php'           
Benchmark 1: php coverage-xml.php
  Time (mean ± σ):     11.772 s ±  0.550 s    [User: 10.209 s, System: 1.237 s]
  Range (min … max):   11.008 s … 12.568 s    10 runs

after this PR:

➜  slow-coverage-xml1 git:(main) ✗ hyperfine 'php coverage-xml.php'
Benchmark 1: php coverage-xml.php
  Time (mean ± σ):      5.999 s ±  0.385 s    [User: 5.008 s, System: 0.789 s]
  Range (min … max):    5.647 s …  6.732 s    10 runs

env

php -v
PHP 8.3.28 (cli) (built: Nov 18 2025 22:17:16) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.3.28, Copyright (c) Zend Technologies

@staabm
Copy link
Contributor Author

staabm commented Nov 22, 2025

double check against phpstan-src@05b80ef861 on my macos m4 pro laptop

before this PR (using PHPUnit 12.4.4)

Generating code coverage report in PHPUnit XML format ... done [00:31.317]

after this PR

Generating code coverage report in PHPUnit XML format ... done [00:17.598]

@sebastianbergmann
Copy link
Owner

Does Infection need the <source> element? If not, we could speed up the XML report generation even more for that use case:

❯ git diff
src/Report/Xml/Facade.php --- 1/2 --- PHP
45        public const string XML_NAMESPACE = 'https://schema.phpunit.de/coverage/1.0';
46        private string $target;
47        private Project $project;
48        private readonly string $phpUnitVersion;
50        public function __construct(string $version)
   49     private readonly bool $includeSource;
   51     public function __construct(string $version, bool $includeSource = true)
   54         $this->includeSource  = $includeSource;
   55     }
   56
   57     /**
   58      * @throws XmlException

src/Report/Xml/Facade.php --- 2/2 --- PHP
169                $coverage = $fileReport->lineCoverage((string) $line);
170                $coverage->finalize($tests);
171            }
   175         if ($this->includeSource) {
   179         }
   180
   181         $this->saveDocument($fileReport->asDom(), $file->id());
   182     }
   183

Of course, we would need to expose this as a configuration option. This is just an idea so far.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants