Speed comparison of PHP source formatters


Formatting open source projects

Various open source projects are formatted with common settings.

Each repository is checked out --hard once before the benchmark is run. .php_cs and .php_cs_cache files are removed to make php-cs-fixer comparable with other formatters.

You can see the command arguments by clicking on the method.

Versions used:

Explanation of results

Results are measured in operations per duration.

Operations can have suffixes like K = 1000 or M = 1,000,000.

Durations are normalized so that the highest magnitude is used.

The method score is based on the average. The fastest method always has a base score of 1x and other methods are compared to it. For example a score of 3x means it's 3 times slower than the fastest method.

You can show or hide the source code of any method by clicking on the .

Method

https://github.com/auraphp/Aura.Sql.git

https://github.com/doctrine/dbal.git

https://github.com/fzaninotto/Faker.git

https://github.com/j4mie/paris.git

https://github.com/sebastianbergmann/phpunit.git

https://github.com/thephpleague/plates.git

https://github.com/slimphp/Slim.git

https://github.com/symfony/yaml.git

https://github.com/twigphp/Twig.git

Score
$ php phormat -n -s
	while ($n--) {
		$phormat->run($parameter);
	}
12 ops in 1 second 10 milliseconds
1 op in 1 second 496 milliseconds
1 op in 2 seconds 228 milliseconds
9 ops in 1 second 21 milliseconds
2 ops in 1 second 371 milliseconds
13 ops in 1 second 84 milliseconds
3 ops in 1 second 35 milliseconds
8 ops in 1 second 47 milliseconds
2 ops in 1 second 59 milliseconds
1 op in 189 milliseconds
1.0
$ 'fmt.phar' --dry-run --psr
	chdir($parameter);
    while ($n--) {
        $phpFmt->run($parameter);
    }
	chdir(__DIR__);
8 ops in 1 second 12 milliseconds
1 op in 1 second 822 milliseconds
1 op in 2 seconds 269 milliseconds
4 ops in 1 second 211 milliseconds
2 ops in 1 second 710 milliseconds
9 ops in 1 second 19 milliseconds
2 ops in 1 second 94 milliseconds
6 ops in 1 second 109 milliseconds
2 ops in 1 second 257 milliseconds
1 op in 290 milliseconds
1.5
$ php-cs-fixer fix --dry-run '--level=psr1'
	chdir($parameter);
    while ($n--) {
        $phpCsFixer->run($parameter);
    }
	chdir(__DIR__);
3 ops in 1 second 234 milliseconds
1 op in 7 seconds 414 milliseconds
1 op in 8 seconds 518 milliseconds
5 ops in 1 second 150 milliseconds
1 op in 5 seconds 585 milliseconds
3 ops in 1 second 326 milliseconds
1 op in 1 second 820 milliseconds
2 ops in 1 second 265 milliseconds
1 op in 4 seconds 315 milliseconds
1 op in 760 milliseconds
4.0
$ php-cs-fixer fix --dry-run '--level=psr2'
	chdir($parameter);
    while ($n--) {
        $phpCsFixer->run($parameter);
    }
	chdir(__DIR__);
2 ops in 1 second 233 milliseconds
1 op in 15 seconds 325 milliseconds
1 op in 15 seconds 634 milliseconds
2 ops in 1 second 647 milliseconds
1 op in 8 seconds 524 milliseconds
2 ops in 1 second 317 milliseconds
1 op in 3 seconds 319 milliseconds
1 op in 1 second 28 milliseconds
1 op in 6 seconds 445 milliseconds
1 op in 1 second 492 milliseconds
7.9
$ php-cs-fixer fix --dry-run '--level=symfony'
	chdir($parameter);
    while ($n--) {
        $phpCsFixer->run($parameter);
    }
	chdir(__DIR__);
1 op in 1 second 398 milliseconds
1 op in 30 seconds 425 milliseconds
1 op in 38 seconds 769 milliseconds
1 op in 1 second 618 milliseconds
1 op in 18 seconds 769 milliseconds
1 op in 1 second 240 milliseconds
1 op in 6 seconds 553 milliseconds
1 op in 1 second 806 milliseconds
1 op in 9 seconds 635 milliseconds
1 op in 2 seconds 939 milliseconds
15.6

nochso/Benchmark
0.5.2
ran each test
> 1000 ms
on
in
235.8 seconds
using PHP
7.0.5-3+donate.sury.org~wily+1
with
Zend OPcache
on
Linux 4.2.0-35-genericx86_64