3v4l.org

run code in 300+ PHP versions simultaneously
<?php function e($n,$p,$c=0){static $a;@krsort($a[$n]);if($c)$a[$n][$p][]=$c;else foreach($a[$n] as$q)foreach($q as$r)$r($p);} function it($m,$p){echo ($p?'✔︎':'✘')." It $m\n"; if(!$p){$GLOBALS['f']=1;}}function done(){if(@$GLOBALS['f'])die(1);} ob_start(); e( 'event', 0, function ($data) { echo "event, $data, priority 0;"; } ); e( 'event', 10, function ($data) { echo "event, $data, priority 10;"; } ); e( 'other_event', -5, function ($data) { echo "other_event, $data, priority -5;"; } ); e( 'other_event', 5, function ($data) { echo "other_event, $data priority 5;"; } ); e('event', 'dataX'); e('other_event', 'dataY'); $output = ob_get_contents(); ob_end_clean(); it( 'calls event listeners in the right order', $output === 'event, dataX, priority 10;event, dataX, priority 0;other_event, dataY priority 5;other_event, dataY, priority -5;' ); class Foo { private $eventDispatcher; function __construct($eventDispatcher) { var_dump($eventDispatcher); $this->eventDispatcher = $eventDispatcher; } function doStuff() { // ... call_user_func($this->eventDispatcher, "my_event", "my data"); } } ob_start(); $foo = new Foo(@e); e("my_event", 5, function($data) { echo "My event was called with '$data'";}); $foo->doStuff(); $output = ob_get_contents();ob_end_clean(); it( 'is perfectly possible to inject the event dispatcher as a dependency into classes.', $output === "My event was called with 'my data'" );

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.0040.01118.43
8.3.50.0100.01121.32
8.3.40.0040.01118.79
8.3.30.0210.00018.92
8.3.20.0000.00820.48
8.3.10.0040.00420.52
8.3.00.0000.00819.50
8.2.180.0090.00916.63
8.2.170.0110.00322.96
8.2.160.0030.01120.44
8.2.150.0040.00424.18
8.2.140.0060.00324.66
8.2.130.0040.00426.16
8.2.120.0040.00422.18
8.2.110.0030.00622.16
8.2.100.0120.00019.76
8.2.90.0040.00419.48
8.2.80.0040.00417.97
8.2.70.0080.00317.50
8.2.60.0000.00818.05
8.2.50.0030.00918.07
8.2.40.0030.00518.28
8.2.30.0080.00019.45
8.2.20.0070.00017.90
8.2.10.0050.00218.21
8.2.00.0000.00717.95
8.1.280.0150.00625.92
8.1.270.0030.00523.80
8.1.260.0040.00426.35
8.1.250.0040.00428.09
8.1.240.0080.00023.83
8.1.230.0090.00319.23
8.1.220.0050.00317.91
8.1.210.0000.00818.77
8.1.200.0100.00017.47
8.1.190.0030.00517.48
8.1.180.0000.00818.10
8.1.170.0050.00318.60
8.1.160.0050.00222.05
8.1.150.0070.00018.96
8.1.140.0030.00517.45
8.1.130.0030.00317.95
8.1.120.0040.00417.51
8.1.110.0040.00417.51
8.1.100.0040.00417.46
8.1.90.0070.00017.45
8.1.80.0040.00417.55
8.1.70.0050.00317.46
8.1.60.0030.00617.57
8.1.50.0050.00317.56
8.1.40.0040.00417.56
8.1.30.0000.00917.64
8.1.20.0040.00417.71
8.1.10.0040.00417.59
8.1.00.0030.00517.47
8.0.300.0040.00418.77
8.0.290.0040.00416.88
8.0.280.0000.00718.50
8.0.270.0080.00017.25
8.0.260.0040.00417.36
8.0.250.0070.00017.05
8.0.240.0030.00317.08
8.0.230.0040.00417.01
8.0.220.0070.00017.00
8.0.210.0040.00417.03
8.0.200.0000.00717.00
8.0.190.0000.00817.13
8.0.180.0040.00417.06
8.0.170.0030.00516.88
8.0.160.0040.00417.00
8.0.150.0000.00716.95
8.0.140.0070.00016.90
8.0.130.0000.00613.41
8.0.120.0000.00816.99
8.0.110.0000.00717.04
8.0.100.0040.00416.91
8.0.90.0040.00417.02
8.0.80.0130.00317.01
8.0.70.0050.00217.03
8.0.60.0040.00416.98
8.0.50.0000.00817.02
8.0.30.0080.01217.34
8.0.20.0100.01017.42
8.0.10.0080.00016.99
8.0.00.0070.01116.88
7.4.330.0020.00215.09
7.4.320.0000.00616.50
7.4.300.0060.00016.43
7.4.290.0050.00316.56
7.4.280.0050.00516.67
7.4.270.0030.00316.57
7.4.260.0000.00716.58
7.4.250.0050.00216.54
7.4.240.0040.00316.64
7.4.230.0000.00716.66
7.4.220.0060.01316.69
7.4.210.0060.00916.71
7.4.200.0070.00016.69
7.4.160.0070.01716.63
7.4.150.0180.00017.40
7.4.140.0070.01117.86
7.4.130.0130.00416.65
7.4.120.0080.00916.63
7.4.110.0170.00016.43
7.4.100.0090.00916.69
7.4.90.0170.00616.52
7.4.80.0060.01516.45
7.4.70.0040.01216.68
7.4.60.0060.01016.50
7.4.50.0040.00416.55
7.4.40.0130.00316.69
7.4.30.0070.01016.55
7.4.00.0030.01414.86
7.3.330.0060.00013.34
7.3.320.0060.00013.46
7.3.310.0030.00316.27
7.3.300.0000.00716.39
7.3.290.0070.00716.47
7.3.280.0130.00616.47
7.3.270.0040.01417.40
7.3.260.0100.00716.53
7.3.250.0100.00916.49
7.3.240.0060.01116.48
7.3.230.0090.00916.53
7.3.210.0110.00716.66
7.3.200.0140.00519.39
7.3.190.0140.01016.57
7.3.180.0060.01216.53
7.3.170.0070.01516.46
7.3.160.0030.01216.55
7.2.330.0090.00816.78
7.2.320.0070.01316.46
7.2.310.0070.01716.61
7.2.300.0070.01016.76
7.2.290.0000.02116.65
7.2.00.0000.01019.32
7.1.100.0120.00818.25
7.1.70.0000.00717.09
7.1.60.0030.02219.32
7.1.50.0150.00616.92
7.1.00.0000.08022.44
7.0.200.0000.00816.91
7.0.140.0030.07321.92
7.0.60.0100.07319.92
7.0.50.0100.07717.72
7.0.40.0100.08320.04
7.0.30.0370.07720.15
7.0.20.0200.05020.07
7.0.10.0070.05720.22
7.0.00.0000.09320.12
5.6.280.0130.06321.12
5.6.210.0070.07720.63
5.6.200.0170.07018.15
5.6.190.0030.05720.50
5.6.180.0300.07720.47
5.6.170.0230.07720.47
5.6.160.0070.07020.46
5.6.150.0100.07018.24
5.6.140.0070.04018.14
5.6.130.0030.06718.28
5.6.120.0000.04321.07
5.6.110.0030.04021.14
5.6.100.0130.07021.00
5.6.90.0130.07320.99
5.6.80.0070.08020.43
5.5.350.0070.07720.54
5.5.340.0000.04717.99
5.5.330.0030.05320.38
5.5.320.0430.07020.36
5.5.310.0230.07020.30
5.5.300.0070.03717.96
5.5.290.0070.04718.08
5.5.280.0000.08720.82
5.5.270.0000.04720.78
5.5.260.0100.08320.86
5.5.250.0100.07020.63
5.5.240.0170.08020.07
5.4.450.0030.06319.53
5.4.440.0630.07019.70
5.4.430.0730.05719.46
5.4.420.0900.06319.61
5.4.410.0770.04719.47
5.4.400.0930.05719.16
5.4.390.0800.06719.14
5.4.380.0470.06718.63
5.4.370.0470.06018.61
5.4.360.0400.05318.75
5.4.350.0330.05318.62
5.4.340.0470.05718.77
5.4.320.0060.03612.53
5.4.310.0070.03712.52
5.4.300.0080.03412.52
5.4.290.0050.04012.52
5.4.280.0040.03812.42
5.4.270.0040.03912.41
5.4.260.0090.04112.42
5.4.250.0090.03412.41
5.4.240.0060.03912.42
5.4.230.0070.03612.41
5.4.220.0060.03612.41
5.4.210.0060.03512.41
5.4.200.0040.03912.41
5.4.190.0060.03612.40
5.4.180.0050.03612.40
5.4.170.0070.03512.42
5.4.160.0050.03612.41
5.4.150.0080.03312.41
5.4.140.0040.03912.09
5.4.130.0070.03512.09
5.4.120.0070.03712.04
5.4.110.0050.03712.03
5.4.100.0090.03612.03
5.4.90.0040.03812.04
5.4.80.0060.03712.04
5.4.70.0050.03612.04
5.4.60.0050.03512.03
5.4.50.0080.03612.03
5.4.40.0060.03712.02
5.4.30.0040.04012.02
5.4.20.0080.03512.02
5.4.10.0050.03512.02
5.4.00.0070.03511.51
5.3.290.0070.03912.80
5.3.280.0060.03712.71
5.3.270.0060.04412.73
5.3.260.0060.04012.73
5.3.250.0060.03812.73
5.3.240.0060.04312.73
5.3.230.0120.04112.73
5.3.220.0090.04312.69
5.3.210.0080.03912.69
5.3.200.0070.04012.69
5.3.190.0100.03312.69
5.3.180.0050.03712.69
5.3.170.0050.03812.69
5.3.160.0050.03712.69
5.3.150.0040.04712.69
5.3.140.0060.03612.68
5.3.130.0040.04012.67
5.3.120.0040.04212.67
5.3.110.0120.04012.67
5.3.100.0030.03912.16
5.3.90.0060.04012.14
5.3.80.0070.03512.12
5.3.70.0100.03912.12
5.3.60.0080.03412.11
5.3.50.0110.03112.05
5.3.40.0050.03712.05
5.3.30.0040.03712.02
5.3.20.0050.03511.80
5.3.10.0040.03911.77
5.3.00.0060.03811.75
5.2.170.0060.0339.24
5.2.160.0040.0299.24
5.2.150.0050.0329.24
5.2.140.0100.0329.23
5.2.130.0070.0289.20
5.2.120.0040.0299.19
5.2.110.0050.0299.20
5.2.100.0090.0369.19
5.2.90.0050.0309.19
5.2.80.0050.0329.19
5.2.70.0020.0339.18
5.2.60.0060.0319.14
5.2.50.0070.0319.11
5.2.40.0040.0299.09
5.2.30.0040.0299.06
5.2.20.0040.0299.05
5.2.10.0050.0278.95
5.2.00.0040.0348.82
5.1.60.0030.0318.11
5.1.50.0060.0258.10
5.1.40.0050.0248.08
5.1.30.0040.0338.43
5.1.20.0070.0248.45
5.1.10.0040.0278.18
5.1.00.0060.0298.18
5.0.50.0060.0306.65
5.0.40.0050.0276.52
5.0.30.0050.0336.32
5.0.20.0050.0196.29
5.0.10.0020.0226.28
5.0.00.0020.0326.27
4.4.90.0020.0194.78
4.4.80.0020.0164.76
4.4.70.0010.0244.76
4.4.60.0030.0204.75
4.4.50.0020.0164.77
4.4.40.0030.0354.70
4.4.30.0010.0184.76
4.4.20.0040.0214.84
4.4.10.0030.0204.85
4.4.00.0050.0294.76
4.3.110.0030.0194.66
4.3.100.0010.0174.66
4.3.90.0050.0124.63
4.3.80.0040.0234.58
4.3.70.0040.0154.63
4.3.60.0030.0144.63
4.3.50.0050.0154.63
4.3.40.0070.0234.54
4.3.30.0030.0213.31
4.3.20.0030.0143.29
4.3.10.0050.0123.25
4.3.00.0070.0206.86

preferences:
36.29 ms | 401 KiB | 5 Q