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]

@staabm staabm force-pushed the dom3 branch 2 times, most recently from c9a346b to b5a8841 Compare November 22, 2025 10:37
@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.

@staabm
Copy link
Contributor Author

staabm commented Nov 27, 2025

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

great idea.

I did some testing and it seems the source element is not required for infection. will double check with the infection team though.

I also did some perf testing on phpstan-src and I can see a ~15% perf improvement when source is not at all generated.

I think we should tackle this in a separate PR though


for this PR here to continue we need a release of the xml-tokenizer including theseer/tokenizer#38 though

@staabm staabm changed the title Drop DOM dependency Drop DOM dependency in XML Report Nov 27, 2025
@sebastianbergmann
Copy link
Owner

I think we should tackle this in a separate PR though

Of course.

c1888bb will be released in time for PHPUnit 12.5 which uses this for sebastianbergmann/phpunit@023845a.

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