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) { die(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.0030.01318.56
8.3.50.0130.00521.28
8.3.40.0120.00318.92
8.3.30.0080.00819.09
8.3.20.0050.00320.26
8.3.10.0030.00620.66
8.3.00.0080.00019.38
8.2.180.0030.01116.63
8.2.170.0110.00422.96
8.2.160.0140.00320.70
8.2.150.0080.00024.18
8.2.140.0080.00024.66
8.2.130.0040.00426.16
8.2.120.0000.00822.09
8.2.110.0100.00021.11
8.2.100.0110.00018.34
8.2.90.0050.00319.25
8.2.80.0030.00617.97
8.2.70.0000.00817.75
8.2.60.0040.00417.93
8.2.50.0120.00018.07
8.2.40.0000.00818.16
8.2.30.0030.00519.39
8.2.20.0000.00817.83
8.2.10.0000.00718.20
8.2.00.0000.00717.87
8.1.280.0100.01025.92
8.1.270.0050.00323.97
8.1.260.0080.00026.35
8.1.250.0070.00028.09
8.1.240.0070.00323.84
8.1.230.0060.00617.83
8.1.220.0050.00317.79
8.1.210.0060.00318.77
8.1.200.0090.00017.48
8.1.190.0050.00317.13
8.1.180.0040.00418.10
8.1.170.0000.00918.84
8.1.160.0050.00321.96
8.1.150.0000.00719.02
8.1.140.0050.00217.51
8.1.130.0030.00317.80
8.1.120.0040.00417.54
8.1.110.0040.00417.55
8.1.100.0000.00817.45
8.1.90.0040.00417.43
8.1.80.0000.00817.53
8.1.70.0000.00717.43
8.1.60.0090.00017.64
8.1.50.0080.00017.50
8.1.40.0080.00017.55
8.1.30.0030.00617.66
8.1.20.0040.00417.66
8.1.10.0030.00517.64
8.1.00.0030.00517.45
8.0.300.0000.00818.77
8.0.290.0040.00416.88
8.0.280.0040.00418.52
8.0.270.0040.00417.37
8.0.260.0030.00318.43
8.0.250.0040.00416.96
8.0.240.0030.00317.10
8.0.230.0000.00817.07
8.0.220.0070.00017.01
8.0.210.0070.00016.91
8.0.200.0030.00316.95
8.0.190.0050.00217.02
8.0.180.0050.00216.95
8.0.170.0050.00316.95
8.0.160.0000.00717.04
8.0.150.0070.00016.92
8.0.140.0040.00416.87
8.0.130.0060.00013.38
8.0.120.0040.00416.88
8.0.110.0040.00416.98
8.0.100.0000.00816.91
8.0.90.0000.00716.83
8.0.80.0060.01017.00
8.0.70.0050.00217.03
8.0.60.0030.00517.10
8.0.50.0000.00717.03
8.0.30.0160.00417.07
8.0.20.0110.00817.40
8.0.10.0000.00916.97
8.0.00.0100.00816.83
7.4.330.0020.00215.12
7.4.320.0000.00716.51
7.4.300.0000.00716.71
7.4.290.0000.00816.65
7.4.280.0000.01016.56
7.4.270.0050.00316.72
7.4.260.0050.00316.63
7.4.250.0000.00716.67
7.4.240.0020.00516.63
7.4.230.0000.00716.70
7.4.220.0120.00616.69
7.4.210.0070.00716.53
7.4.200.0030.00316.77
7.4.160.0150.00916.57
7.4.150.0130.01317.40
7.4.140.0100.00817.86
7.4.130.0020.01516.50
7.4.120.0100.00916.59
7.4.110.0120.00416.49
7.4.100.0100.01016.66
7.4.90.0140.00816.48
7.4.80.0140.00416.50
7.4.70.0100.00616.63
7.4.60.0100.00716.75
7.4.50.0050.00016.62
7.4.40.0060.01016.36
7.4.30.0100.01016.45
7.4.00.0030.00914.69
7.3.330.0000.00613.45
7.3.320.0050.00013.29
7.3.310.0000.00916.56
7.3.300.0030.00516.47
7.3.290.0060.01216.45
7.3.280.0090.00816.46
7.3.270.0090.00917.40
7.3.260.0070.01116.63
7.3.250.0130.00716.40
7.3.240.0080.00816.67
7.3.230.0070.01116.67
7.3.210.0130.00616.71
7.3.200.0070.01419.39
7.3.190.0190.00716.55
7.3.180.0090.01316.55
7.3.170.0100.00716.41
7.3.160.0080.00816.59
7.3.10.0240.01016.60
7.3.00.0140.01116.48
7.2.330.0110.00516.71
7.2.320.0100.01316.88
7.2.310.0100.01016.84
7.2.300.0150.00516.61
7.2.290.0090.01216.83
7.2.130.0140.00016.80
7.2.120.0060.01016.49
7.2.110.0100.00716.52
7.2.100.0070.01016.64
7.2.90.0200.00616.90
7.2.80.0120.00616.36
7.2.70.0100.00716.72
7.2.60.0100.00816.73
7.2.50.0070.01116.47
7.2.40.0140.00416.94
7.2.30.0100.00716.80
7.2.20.0100.00716.76
7.2.10.0130.00616.75
7.2.00.0100.00618.09
7.1.250.0190.01315.51
7.1.200.0060.00615.78
7.1.100.0140.00718.00
7.1.70.0040.00417.32
7.1.60.0070.01719.32
7.1.50.0030.02016.98
7.1.00.0030.07322.31
7.0.200.0070.00016.91
7.0.140.0030.07321.97
7.0.60.0030.09319.95
7.0.50.0000.09017.85
7.0.40.0030.06720.40
7.0.30.0330.07320.24
7.0.20.0330.07320.05
7.0.10.0070.06020.02
7.0.00.0100.08020.25
5.6.210.0170.07720.63
5.6.200.0200.06318.22
5.6.190.0030.08320.63
5.6.180.0330.05020.55
5.6.170.0130.05320.57
5.6.160.0100.08720.59
5.6.150.0130.04318.19
5.6.140.0000.04318.29
5.6.130.0130.07718.17
5.6.120.0100.08320.79
5.6.110.0130.08321.03
5.6.100.0130.07021.01
5.6.90.0170.06721.01
5.6.80.0100.07320.59
5.5.350.0270.07020.35
5.5.340.0070.03718.05
5.5.330.0070.08320.27
5.5.320.0300.06320.24
5.5.310.0200.06320.51
5.5.300.0170.05318.02
5.5.290.0170.07017.95
5.5.280.0030.06020.88
5.5.270.0070.04720.80
5.5.260.0100.07720.70
5.5.250.0170.05020.48
5.5.240.0100.07720.39
5.4.450.0330.05719.20
5.4.440.1000.07319.39
5.4.430.1030.07019.45
5.4.420.0830.05019.46
5.4.410.0970.06319.45
5.4.400.0800.05719.31
5.4.390.0030.06018.87
5.4.380.0330.08018.90
5.4.370.0370.05718.81
5.4.360.0330.06018.71
5.4.350.0330.05318.52
5.4.340.0430.05018.80
5.4.320.0080.03512.52
5.4.310.0070.03712.52
5.4.300.0040.04012.52
5.4.290.0060.03712.52
5.4.280.0080.03312.42
5.4.270.0080.03412.42
5.4.260.0100.03312.42
5.4.250.0080.04612.41
5.4.240.0070.03612.42
5.4.230.0090.03612.41
5.4.220.0080.03612.41
5.4.210.0050.03912.41
5.4.200.0080.04012.41
5.4.190.0090.04012.41
5.4.180.0070.04212.41
5.4.170.0020.04012.42
5.4.160.0120.03612.41
5.4.150.0070.03512.41
5.4.140.0050.03812.09
5.4.130.0070.03412.08
5.4.120.0080.03312.04
5.4.110.0100.03112.04
5.4.100.0030.03712.04
5.4.90.0080.03512.04
5.4.80.0040.04012.04
5.4.70.0090.03112.04
5.4.60.0060.03412.03
5.4.50.0090.04312.03
5.4.40.0140.04712.02
5.4.30.0050.03812.02
5.4.20.0100.03412.02
5.4.10.0050.03512.01
5.4.00.0080.03411.50
5.3.290.0080.04112.80
5.3.280.0060.04012.71
5.3.270.0050.04012.72
5.3.260.0050.04412.73
5.3.250.0080.03512.73
5.3.240.0050.04212.73
5.3.230.0070.03612.73
5.3.220.0040.04312.69
5.3.210.0090.03712.69
5.3.200.0050.03812.70
5.3.190.0050.03812.70
5.3.180.0090.03312.69
5.3.170.0040.03912.69
5.3.160.0070.03612.69
5.3.150.0080.03512.69
5.3.140.0090.03712.68
5.3.130.0090.04812.67
5.3.120.0050.04112.68
5.3.110.0060.04312.68
5.3.100.0100.03912.16
5.3.90.0030.04412.14
5.3.80.0070.03612.13
5.3.70.0060.03612.13
5.3.60.0030.03912.12
5.3.50.0050.03712.05
5.3.40.0050.03912.06
5.3.30.0080.03912.02
5.3.20.0040.03811.80
5.3.10.0080.03611.77
5.3.00.0070.03611.75
5.2.170.0040.0319.23
5.2.160.0050.0299.23
5.2.150.0040.0319.23
5.2.140.0060.0299.23
5.2.130.0070.0259.19
5.2.120.0060.0279.20
5.2.110.0050.0289.20
5.2.100.0030.0309.19
5.2.90.0050.0289.20
5.2.80.0060.0299.18
5.2.70.0070.0349.19
5.2.60.0060.0299.15
5.2.50.0070.0279.12
5.2.40.0060.0289.09
5.2.30.0070.0319.06
5.2.20.0050.0349.05
5.2.10.0050.0288.96
5.2.00.0080.0298.82
5.1.60.0050.0228.10
5.1.50.0040.0308.11
5.1.40.0040.0248.07
5.1.30.0050.0278.43
5.1.20.0040.0268.45
5.1.10.0050.0308.18
5.1.00.0040.0268.18
5.0.50.0050.0196.65
5.0.40.0050.0186.52
5.0.30.0050.0296.33
5.0.20.0030.0216.29
5.0.10.0020.0216.28
5.0.00.0020.0326.27
4.4.90.0030.0154.78
4.4.80.0020.0164.75
4.4.70.0060.0124.75
4.4.60.0030.0164.75
4.4.50.0010.0184.77
4.4.40.0030.0274.71
4.4.30.0050.0174.76
4.4.20.0030.0154.84
4.4.10.0040.0144.85
4.4.00.0020.0264.76
4.3.110.0030.0154.67
4.3.100.0030.0154.66
4.3.90.0020.0164.64
4.3.80.0070.0204.58
4.3.70.0000.0174.63
4.3.60.0050.0114.63
4.3.50.0020.0184.63
4.3.40.0030.0284.54
4.3.30.0010.0173.31
4.3.20.0020.0163.29
4.3.10.0020.0233.25
4.3.00.0000.0306.86

preferences:
42.82 ms | 401 KiB | 5 Q