3v4l.org

run code in 300+ PHP versions simultaneously
<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Doctrine\Tests\DependencyInjection\CompilerPass; use Symfony\Bridge\Doctrine\DependencyInjection\CompilerPass\RegisterEventListenersAndSubscribersPass; use Symfony\Component\DependencyInjection\ContainerBuilder; class RegisterEventListenersAndSubscribersPassTest extends \PHPUnit_Framework_TestCase { public function testProcessEventListenersWithPriorities() { $container = $this->createBuilder(); $container ->register('a', 'stdClass') ->addTag('doctrine.event_listener', array( 'event' => 'foo', 'priority' => -5, )) ->addTag('doctrine.event_listener', array( 'event' => 'bar', )) ; $container ->register('b', 'stdClass') ->addTag('doctrine.event_listener', array( 'event' => 'foo', )) ; $this->process($container); $this->assertEquals(array('b', 'a'), $this->getServiceOrder($container, 'addEventListener')); $calls = $container->getDefinition('doctrine.dbal.default_connection.event_manager')->getMethodCalls(); $this->assertEquals(array('foo', 'bar'), $calls[1][1][0]); } public function testProcessEventListenersWithMultipleConnections() { $container = $this->createBuilder(true); $container ->register('a', 'stdClass') ->addTag('doctrine.event_listener', array( 'event' => 'onFlush', )) ; $this->process($container); $callsDefault = $container->getDefinition('doctrine.dbal.default_connection.event_manager')->getMethodCalls(); $this->assertEquals('addEventListener', $callsDefault[0][0]); $this->assertEquals(array('onFlush'), $callsDefault[0][1][0]); $callsSecond = $container->getDefinition('doctrine.dbal.second_connection.event_manager')->getMethodCalls(); $this->assertEquals($callsDefault, $callsSecond); } public function testProcessEventSubscribersWithPriorities() { $container = $this->createBuilder(); $container ->register('a', 'stdClass') ->addTag('doctrine.event_subscriber') ; $container ->register('b', 'stdClass') ->addTag('doctrine.event_subscriber', array( 'priority' => 5, )) ; $container ->register('c', 'stdClass') ->addTag('doctrine.event_subscriber', array( 'priority' => 10, )) ; $container ->register('d', 'stdClass') ->addTag('doctrine.event_subscriber', array( 'priority' => 10, )) ; $container ->register('e', 'stdClass') ->addTag('doctrine.event_subscriber', array( 'priority' => 10, )) ; $this->process($container); $this->assertEquals(array('c', 'd', 'e', 'b', 'a'), $this->getServiceOrder($container, 'addEventSubscriber')); } public function testProcessNoTaggedServices() { $container = $this->createBuilder(true); $this->process($container); $this->assertEquals(array(), $container->getDefinition('doctrine.dbal.default_connection.event_manager')->getMethodCalls()); $this->assertEquals(array(), $container->getDefinition('doctrine.dbal.second_connection.event_manager')->getMethodCalls()); } private function process(ContainerBuilder $container) { $pass = new RegisterEventListenersAndSubscribersPass('doctrine.connections', 'doctrine.dbal.%s_connection.event_manager', 'doctrine'); $pass->process($container); } private function getServiceOrder(ContainerBuilder $container, $method) { $order = array(); foreach ($container->getDefinition('doctrine.dbal.default_connection.event_manager')->getMethodCalls() as $call) { list($name, $arguments) = $call; if ($method !== $name) { continue; } if ('addEventListener' === $name) { $order[] = (string) $arguments[1]; continue; } $order[] = (string) $arguments[0]; } return $order; } private function createBuilder($multipleConnections = false) { $container = new ContainerBuilder(); $connections = array('default' => 'doctrine.dbal.default_connection'); $container->register('doctrine.dbal.default_connection.event_manager', 'stdClass'); $container->register('doctrine.dbal.default_connection', 'stdClass'); if ($multipleConnections) { $container->register('doctrine.dbal.second_connection.event_manager', 'stdClass'); $container->register('doctrine.dbal.second_connection', 'stdClass'); $connections['second'] = 'doctrine.dbal.second_connection'; } $container->setParameter('doctrine.connections', $connections); return $container; } }

Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).

VersionSystem time (s)User time (s)Memory (MiB)
8.3.60.0140.00016.88
8.3.50.0080.00823.00
8.3.40.0150.00619.00
8.3.30.0120.00319.03
8.3.20.0030.00520.34
8.3.10.0070.01123.68
8.3.00.0080.00019.38
8.2.180.0090.00618.29
8.2.170.0100.00722.96
8.2.160.0040.01120.52
8.2.150.0050.00324.18
8.2.140.0120.00624.66
8.2.130.0080.00026.16
8.2.120.0040.00420.92
8.2.110.0030.00620.55
8.2.100.0080.00317.91
8.2.90.0040.00417.91
8.2.80.0040.00419.15
8.2.70.0050.00317.93
8.2.60.0000.01017.79
8.2.50.0120.00618.10
8.2.40.0060.00320.59
8.2.30.0050.00219.41
8.2.20.0030.00517.82
8.2.10.0040.00418.30
8.2.00.0030.00617.71
8.1.280.0070.00725.92
8.1.270.0080.00023.96
8.1.260.0000.00826.35
8.1.250.0070.00728.09
8.1.240.0030.00624.02
8.1.230.0040.00720.91
8.1.220.0040.00417.79
8.1.210.0000.00818.79
8.1.200.0000.00917.35
8.1.190.0030.00517.48
8.1.180.0060.00318.10
8.1.170.0040.00418.57
8.1.160.0040.00422.07
8.1.150.0040.00418.88
8.1.140.0040.00417.32
8.1.130.0030.00317.77
8.1.120.0040.00417.35
8.1.110.0080.00017.48
8.1.100.0000.00817.44
8.1.90.0040.00417.46
8.1.80.0080.00017.44
8.1.70.0000.00717.39
8.1.60.0000.00817.43
8.1.50.0030.00617.56
8.1.40.0040.00417.38
8.1.30.0030.00517.65
8.1.20.0040.00417.66
8.1.10.0000.00817.43
8.1.00.0040.00417.47
8.0.300.0040.00420.27
8.0.290.0040.00416.75
8.0.280.0040.00418.43
8.0.270.0070.00316.95
8.0.260.0030.00317.24
8.0.250.0000.00717.02
8.0.240.0000.00716.99
8.0.230.0000.00717.10
8.0.220.0000.00716.91
8.0.210.0030.00516.91
8.0.200.0040.00416.94
8.0.190.0040.00417.04
8.0.180.0030.00616.93
8.0.170.0000.00717.07
8.0.160.0040.00417.00
8.0.150.0040.00416.93
8.0.140.0000.00816.97
8.0.130.0000.00513.51
8.0.120.0030.00516.91
8.0.110.0030.00516.92
8.0.100.0000.00817.11
8.0.90.0030.00516.95
8.0.80.0100.01316.92
8.0.70.0040.00417.07
8.0.60.0030.00516.87
8.0.50.0080.00016.91
8.0.30.0130.00617.13
8.0.20.0120.00717.40
8.0.10.0040.00416.97
8.0.00.0060.01116.88
7.4.330.0050.00015.14
7.4.320.0040.00416.59
7.4.300.0030.00316.64
7.4.290.0000.00716.41
7.4.280.0070.00016.50
7.4.270.0070.00016.45
7.4.260.0050.00216.55
7.4.250.0040.00416.43
7.4.240.0020.00516.49
7.4.230.0030.00316.62
7.4.220.0090.01016.70
7.4.210.0000.01616.70
7.4.200.0070.00016.31
7.4.160.0100.01416.52
7.4.150.0110.01117.40
7.4.140.0090.01217.86
7.4.130.0110.00616.59
7.4.120.0130.00616.47
7.4.110.0100.00616.53
7.4.100.0120.00616.68
7.4.90.0100.00716.64
7.4.80.0080.01619.39
7.4.70.0090.00616.50
7.4.60.0150.00316.39
7.4.50.0050.00216.68
7.4.40.0060.01016.29
7.4.30.0140.00316.57
7.4.00.0000.01515.05
7.3.330.0000.00513.36
7.3.320.0000.00513.23
7.3.310.0000.00716.43
7.3.300.0000.00716.36
7.3.290.0060.00916.30
7.3.280.0110.00816.35
7.3.270.0080.00817.40
7.3.260.0100.00616.41
7.3.250.0080.00816.37
7.3.240.0100.00516.48
7.3.230.0100.00716.61
7.3.210.0100.00716.54
7.3.200.0120.00619.39
7.3.190.0030.01716.47
7.3.180.0100.01016.43
7.3.170.0030.01316.50
7.3.160.0170.00016.40
7.2.330.0150.00316.76
7.2.320.0070.01016.37
7.2.310.0120.00616.39
7.2.300.0160.00816.63
7.2.290.0130.00316.57
7.2.60.0030.01016.54
7.1.200.0000.01215.43
7.1.70.0030.01317.10
7.1.60.0150.00919.46
7.1.50.0140.01116.78
7.1.00.0030.07722.48
7.0.200.0070.00016.73
7.0.140.0030.07322.18
7.0.60.0070.08720.04
7.0.50.0030.05717.88
7.0.40.0030.09320.21
7.0.30.0330.08020.21
7.0.20.0170.04320.15
7.0.10.0000.04720.07
7.0.00.0100.05720.25
5.6.280.0100.07021.19
5.6.210.0030.06320.50
5.6.200.0030.05018.21
5.6.190.0070.06020.61
5.6.180.0300.04320.46
5.6.170.0300.03020.54
5.6.160.0030.08720.55
5.6.150.0030.08718.25
5.6.140.0070.07718.18
5.6.130.0100.04018.19
5.6.120.0070.08320.83
5.6.110.0100.07721.16
5.6.100.0070.07021.05
5.6.90.0170.06721.04
5.6.80.0100.07720.54
5.5.350.0200.07320.53
5.5.340.0070.07318.09
5.5.330.0030.04320.32
5.5.320.0070.07020.51
5.5.310.0300.07020.30
5.5.300.0070.07317.96
5.5.290.0070.07317.97
5.5.280.0100.08320.91
5.5.270.0170.07720.79
5.5.260.0130.07720.83
5.5.250.0100.03320.61
5.5.240.0230.06320.41
5.4.450.0230.04719.28
5.4.440.0530.04319.52
5.4.430.0200.04019.31
5.4.420.0270.03719.41
5.4.410.0270.03719.42
5.4.400.0300.03719.06
5.4.390.0170.04718.99
5.4.380.0270.05718.63
5.4.370.0270.05718.84
5.4.360.0370.05718.52
5.4.350.0200.06318.52
5.4.340.0400.07018.52
5.4.320.0080.03412.54
5.4.310.0070.05212.53
5.4.300.0090.03812.54
5.4.290.0110.03812.53
5.4.280.0120.04012.43
5.4.270.0080.03512.43
5.4.260.0050.04412.43
5.4.250.0090.04612.43
5.4.240.0090.03712.43
5.4.230.0040.03912.42
5.4.220.0090.03912.42
5.4.210.0090.04812.42
5.4.200.0060.04712.42
5.4.190.0120.04312.42
5.4.180.0050.03612.42
5.4.170.0080.04312.43
5.4.160.0060.04412.42
5.4.150.0040.03712.42
5.4.140.0050.03712.10
5.4.130.0060.03512.09
5.4.120.0040.03712.05
5.4.110.0070.04212.05
5.4.100.0060.04112.04
5.4.90.0040.04312.05
5.4.80.0090.04312.05
5.4.70.0080.03812.04
5.4.60.0050.03912.04
5.4.50.0070.03512.04
5.4.40.0110.03812.03
5.4.30.0100.04512.03
5.4.20.0060.04412.03
5.4.10.0110.04112.03
5.4.00.0030.03711.52
5.3.290.0080.05612.80
5.3.280.0100.03412.73
5.3.270.0080.03812.74
5.3.260.0050.03912.74
5.3.250.0020.05012.74
5.3.240.0110.04212.74
5.3.230.0090.04312.73
5.3.220.0040.04112.70
5.3.210.0060.03812.70
5.3.200.0060.04412.71
5.3.190.0090.04712.70
5.3.180.0060.05412.70
5.3.170.0070.03812.70
5.3.160.0070.04912.70
5.3.150.0090.03812.70
5.3.140.0060.03612.70
5.3.130.0070.03812.68
5.3.120.0040.04112.68
5.3.110.0060.03812.69
5.3.100.0040.03912.17
5.3.90.0050.04112.15
5.3.80.0060.03512.14
5.3.70.0060.03612.14
5.3.60.0090.03412.13
5.3.50.0110.04512.08
5.3.40.0090.04212.08
5.3.30.0060.03812.04
5.3.20.0080.03411.81
5.3.10.0030.03811.78
5.3.00.0080.03411.77
5.2.170.0050.0319.19
5.2.160.0090.0259.18
5.2.150.0050.0349.19
5.2.140.0070.0369.18
5.2.130.0040.0309.14
5.2.120.0030.0339.14
5.2.110.0060.0389.15
5.2.100.0060.0279.15
5.2.90.0040.0309.15
5.2.80.0080.0389.14
5.2.70.0050.0309.14
5.2.60.0050.0339.10
5.2.50.0060.0309.07
5.2.40.0030.0339.04
5.2.30.0090.0259.02
5.2.20.0060.0369.01
5.2.10.0080.0358.93
5.2.00.0060.0288.79
5.1.60.0010.0278.08
5.1.50.0050.0248.07
5.1.40.0060.0298.05
5.1.30.0050.0278.40
5.1.20.0040.0378.43
5.1.10.0040.0308.15
5.1.00.0050.0268.15
5.0.50.0060.0226.62
5.0.40.0030.0306.48
5.0.30.0040.0366.29
5.0.20.0060.0236.27
5.0.10.0040.0256.25
5.0.00.0020.0406.24
4.4.90.0050.0244.78
4.4.80.0040.0204.75
4.4.70.0020.0164.76
4.4.60.0020.0154.76
4.4.50.0040.0234.77
4.4.40.0020.0254.71
4.4.30.0040.0144.76
4.4.20.0050.0134.84
4.4.10.0000.0184.84
4.4.00.0020.0294.76
4.3.110.0020.0174.67
4.3.100.0010.0174.66
4.3.90.0060.0204.63
4.3.80.0050.0264.59
4.3.70.0020.0264.63
4.3.60.0030.0204.63
4.3.50.0040.0144.63
4.3.40.0030.0254.54
4.3.30.0030.0243.29
4.3.20.0020.0223.26
4.3.10.0010.0163.23
4.3.00.0030.01718.56

preferences:
47.04 ms | 401 KiB | 5 Q