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) { $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.70.0140.00018.55
8.3.60.0090.00618.56
8.3.50.0140.00521.19
8.3.40.0070.00718.96
8.3.30.0170.00319.06
8.3.20.0040.00420.25
8.3.10.0080.00020.52
8.3.00.0080.00017.75
8.2.180.0120.00316.75
8.2.170.0070.00722.96
8.2.160.0070.00720.53
8.2.150.0050.00324.18
8.2.140.0030.00524.66
8.2.130.0000.00826.16
8.2.120.0070.00022.17
8.2.110.0060.00322.20
8.2.100.0120.00018.09
8.2.90.0040.00419.23
8.2.80.0030.00517.97
8.2.70.0050.00317.63
8.2.60.0030.00517.93
8.2.50.0040.00818.07
8.2.40.0000.00818.28
8.2.30.0040.00419.26
8.2.20.0040.00417.89
8.2.10.0030.00518.08
8.2.00.0000.00817.82
8.1.280.0070.01025.92
8.1.270.0040.00423.91
8.1.260.0040.00426.35
8.1.250.0070.00028.09
8.1.240.0000.00823.99
8.1.230.0040.00819.28
8.1.220.0040.00417.79
8.1.210.0030.00618.77
8.1.200.0030.00917.60
8.1.190.0000.00917.13
8.1.180.0000.00818.10
8.1.170.0050.00318.68
8.1.160.0070.00022.05
8.1.150.0000.00819.03
8.1.140.0060.00317.52
8.1.130.0030.00317.89
8.1.120.0000.00717.55
8.1.110.0030.00517.54
8.1.100.0080.00017.40
8.1.90.0000.00817.42
8.1.80.0070.00317.56
8.1.70.0030.00517.50
8.1.60.0030.00617.62
8.1.50.0050.00317.64
8.1.40.0040.00417.58
8.1.30.0040.00417.68
8.1.20.0000.00717.72
8.1.10.0040.00417.53
8.1.00.0070.00017.62
8.0.300.0040.00418.77
8.0.290.0000.00816.88
8.0.280.0030.00318.42
8.0.270.0080.00017.36
8.0.260.0000.00617.32
8.0.250.0000.00717.10
8.0.240.0030.00317.09
8.0.230.0030.00317.09
8.0.220.0040.00417.01
8.0.210.0040.00316.96
8.0.200.0000.00617.00
8.0.190.0040.00417.15
8.0.180.0000.00717.03
8.0.170.0050.00316.94
8.0.160.0000.00717.06
8.0.150.0050.00316.86
8.0.140.0030.00516.97
8.0.130.0060.00013.54
8.0.120.0000.00816.88
8.0.110.0020.00516.91
8.0.100.0060.00317.07
8.0.90.0020.00516.94
8.0.80.0120.00317.02
8.0.70.0080.00017.06
8.0.60.0050.00216.92
8.0.50.0040.00417.07
8.0.30.0110.01017.22
8.0.20.0080.01017.40
8.0.10.0080.00016.97
8.0.00.0100.00816.84
7.4.330.0050.00015.00
7.4.320.0060.00016.47
7.4.300.0060.00016.57
7.4.290.0000.00716.58
7.4.280.0070.00416.64
7.4.270.0030.00316.43
7.4.260.0030.00316.55
7.4.250.0040.00416.62
7.4.240.0030.00316.67
7.4.230.0070.00016.78
7.4.220.0060.01316.78
7.4.210.0100.00316.67
7.4.200.0000.00716.56
7.4.160.0120.00616.75
7.4.150.0120.00617.40
7.4.140.0080.00917.86
7.4.130.0100.00916.53
7.4.120.0080.00816.65
7.4.110.0110.00716.67
7.4.100.0060.00816.69
7.4.90.0030.01716.61
7.4.80.0060.01516.57
7.4.70.0100.00716.51
7.4.60.0140.00316.61
7.4.50.0060.00016.32
7.4.40.0110.00616.71
7.4.30.0120.00916.76
7.4.10.0070.01316.29
7.4.00.0100.00715.66
7.3.330.0000.00613.33
7.3.320.0030.00313.48
7.3.310.0040.00416.43
7.3.300.0070.00016.52
7.3.290.0040.01616.44
7.3.280.0100.00716.49
7.3.270.0060.01217.40
7.3.260.0130.00616.52
7.3.250.0060.01216.46
7.3.240.0040.01216.54
7.3.230.0100.01316.52
7.3.210.0090.00916.72
7.3.200.0150.00319.39
7.3.190.0150.00816.41
7.3.180.0100.01416.47
7.3.170.0080.01216.48
7.3.160.0130.00316.61
7.3.130.0080.01216.62
7.3.120.0060.01216.39
7.3.110.0030.00916.38
7.3.100.0060.00916.52
7.3.90.0070.01416.37
7.3.80.0030.01216.45
7.3.70.0100.00616.48
7.3.60.0030.00716.38
7.3.50.0030.01216.47
7.3.40.0040.01116.47
7.3.30.0090.00916.53
7.3.20.0040.00918.27
7.3.10.0140.00018.17
7.3.00.0030.01518.17
7.2.330.0110.00516.78
7.2.320.0070.01716.75
7.2.310.0090.00916.54
7.2.300.0040.01216.80
7.2.290.0130.00416.46
7.2.260.0000.01816.80
7.2.250.0100.01016.72
7.2.240.0040.01216.88
7.2.230.0110.01116.77
7.2.220.0070.01016.77
7.2.210.0100.00616.75
7.2.200.0090.00916.57
7.2.190.0000.01116.50
7.2.180.0030.01316.43
7.2.170.0100.01016.73
7.2.160.0080.01216.57
7.2.150.0040.01218.50
7.2.140.0040.01118.46
7.2.130.0040.01418.56
7.2.120.0030.01418.38
7.2.110.0000.01018.57
7.2.100.0100.00618.42
7.2.90.0090.00618.30
7.2.80.0070.01118.36
7.2.70.0060.00618.65
7.2.60.0000.01718.55
7.2.50.0070.00718.33
7.2.40.0040.00918.50
7.2.30.0030.01018.59
7.2.20.0110.00418.38
7.2.10.0110.00718.47
7.2.00.0050.01118.95
7.1.330.0060.01317.51
7.1.320.0100.00617.35
7.1.310.0030.01417.44
7.1.300.0000.01117.33
7.1.290.0070.00717.38
7.1.280.0130.00717.44
7.1.270.0030.00817.35
7.1.260.0060.00917.40
7.1.250.0070.00717.20
7.1.240.0040.00417.39
7.1.230.0030.00617.21
7.1.220.0130.00317.37
7.1.210.0000.01517.46
7.1.200.0030.00717.44
7.1.190.0110.00317.38
7.1.180.0040.01117.30
7.1.170.0040.01417.48
7.1.160.0070.01017.33
7.1.150.0040.01117.18
7.1.140.0080.00417.29
7.1.130.0090.00617.26
7.1.120.0100.00717.48
7.1.110.0130.00317.31
7.1.100.0080.00817.65
7.1.90.0000.01217.52
7.1.80.0040.01117.36
7.1.70.0050.00717.29
7.1.60.0080.01218.33
7.1.50.0110.00917.18
7.1.40.0110.00417.25
7.1.30.0060.00917.36
7.1.20.0070.01017.39
7.1.10.0030.01317.39
7.1.00.0060.03819.82
7.0.330.0060.00617.06
7.0.320.0140.00417.04
7.0.310.0000.01117.19
7.0.300.0030.01217.20
7.0.290.0070.00717.20
7.0.280.0000.00917.04
7.0.270.0040.01117.12
7.0.260.0060.01317.11
7.0.250.0030.00617.02
7.0.240.0070.00717.30
7.0.230.0030.01217.20
7.0.220.0110.00317.08
7.0.210.0040.01117.21
7.0.200.0050.00816.78
7.0.190.0030.01117.07
7.0.180.0030.01217.14
7.0.170.0060.01217.10
7.0.160.0070.00717.13
7.0.150.0060.00317.02
7.0.140.0040.04119.56
7.0.130.0070.00716.98
7.0.120.0110.00717.09
7.0.110.0060.00617.05
7.0.100.0050.00516.95
7.0.90.0070.00716.84
7.0.80.0030.01016.94
7.0.70.0030.00717.00
7.0.60.0150.03818.62
7.0.50.0060.04117.54
7.0.40.0050.02617.49
7.0.30.0300.03217.58
7.0.20.0130.03517.49
7.0.10.0070.04617.60
7.0.00.0020.04917.60
5.6.400.0040.00715.96
5.6.390.0040.00815.98
5.6.380.0120.00616.13
5.6.370.0030.00916.12
5.6.360.0060.00916.01
5.6.350.0100.00616.15
5.6.340.0000.01116.13
5.6.330.0060.01215.98
5.6.320.0040.00715.81
5.6.310.0090.00916.18
5.6.300.0030.01015.79
5.6.290.0030.01315.95
5.6.280.0070.03718.53
5.6.270.0100.00616.10
5.6.260.0070.00716.00
5.6.250.0100.00715.83
5.6.240.0030.01416.12
5.6.230.0000.01115.95
5.6.220.0100.00715.95
5.6.210.0150.03318.20
5.6.200.0050.02617.04
5.6.190.0050.03418.29
5.6.180.0180.02318.21
5.6.170.0150.02518.41
5.6.160.0150.02818.04
5.6.150.0080.04317.05
5.6.140.0070.02917.15
5.6.130.0090.02817.06
5.6.120.0080.02318.64
5.6.110.0070.04218.60
5.6.100.0140.02218.64
5.6.90.0100.02418.73
5.6.80.0130.03618.23
5.6.70.0100.00716.02
5.6.60.0030.01216.04
5.6.50.0130.00316.01
5.6.40.0110.00415.93
5.6.30.0060.01016.02
5.6.20.0070.00716.13
5.6.10.0090.00315.97
5.6.00.0040.01415.77
5.5.380.0000.01416.04
5.5.370.0040.00715.98
5.5.360.0100.00716.27
5.5.350.0180.03918.27
5.5.340.0080.01817.08
5.5.330.0080.04218.13
5.5.320.0160.02418.06
5.5.310.0100.03818.23
5.5.300.0100.03317.05
5.5.290.0060.02516.98
5.5.280.0050.04218.47
5.5.270.0020.03018.39
5.5.260.0100.04518.28
5.5.250.0030.02718.26
5.5.240.0100.04118.12
5.5.230.0070.00715.93
5.5.220.0030.00915.95
5.5.210.0080.00615.86
5.5.200.0060.00615.88
5.5.190.0060.00915.85
5.5.180.0030.01315.84
5.5.170.0030.01116.03
5.5.160.0060.01116.12
5.5.150.0060.00616.08
5.5.140.0090.00615.75
5.5.130.0110.00416.04
5.5.120.0030.01316.05
5.5.110.0070.00715.78
5.5.100.0100.00316.25
5.5.90.0060.00916.04
5.5.80.0080.00815.98
5.5.70.0040.01116.00
5.5.60.0000.01016.04
5.5.50.0040.00416.02
5.5.40.0030.01415.93
5.5.30.0060.01016.11
5.5.20.0070.00315.81
5.5.10.0060.00615.69
5.5.00.0070.00316.04
5.4.450.0150.03716.15
5.4.440.0530.03816.26
5.4.430.0430.04516.25
5.4.420.0610.02516.14
5.4.410.0410.02915.99
5.4.400.0030.03816.01
5.4.390.0380.03216.09
5.4.380.0270.03015.79
5.4.370.0180.02815.74
5.4.360.0160.03115.83
5.4.350.0200.03315.76
5.4.340.0150.03215.83
5.4.330.0060.01012.84
5.4.320.0040.02812.64
5.4.310.0020.02512.75
5.4.300.0070.02012.71
5.4.290.0040.02812.67
5.4.280.0060.02212.57
5.4.270.0060.02312.60
5.4.260.0040.02812.50
5.4.250.0050.02112.53
5.4.240.0040.02612.59
5.4.230.0020.02412.65
5.4.220.0040.02112.62
5.4.210.0050.01912.70
5.4.200.0060.02112.62
5.4.190.0030.02512.59
5.4.180.0100.01912.52
5.4.170.0080.01912.60
5.4.160.0050.02212.63
5.4.150.0050.02212.62
5.4.140.0080.02112.57
5.4.130.0040.02312.49
5.4.120.0050.02112.51
5.4.110.0040.02312.46
5.4.100.0040.02412.41
5.4.90.0060.02212.42
5.4.80.0070.01912.35
5.4.70.0060.02412.53
5.4.60.0020.02612.53
5.4.50.0080.02612.31
5.4.40.0050.02912.40
5.4.30.0060.02212.44
5.4.20.0060.02312.36
5.4.10.0040.02212.40
5.4.00.0070.02412.13
5.3.290.0060.03912.80
5.3.280.0070.03712.71
5.3.270.0040.04012.72
5.3.260.0110.03512.73
5.3.250.0090.03512.73
5.3.240.0070.03912.73
5.3.230.0090.03612.73
5.3.220.0070.03812.70
5.3.210.0080.03612.69
5.3.200.0070.03812.69
5.3.190.0050.03812.69
5.3.180.0080.03512.69
5.3.170.0040.03812.69
5.3.160.0070.03812.69
5.3.150.0030.03912.68
5.3.140.0060.03612.68
5.3.130.0080.03712.67
5.3.120.0030.04112.67
5.3.110.0060.04512.68
5.3.100.0050.04512.16
5.3.90.0070.03512.14
5.3.80.0070.04212.13
5.3.70.0070.04712.13
5.3.60.0050.03812.11
5.3.50.0100.03212.06
5.3.40.0090.04312.06
5.3.30.0070.03912.02
5.3.20.0070.04311.80
5.3.10.0060.03411.77
5.3.00.0040.04411.75
5.2.170.0040.0319.23
5.2.160.0060.0289.24
5.2.150.0040.0339.23
5.2.140.0060.0299.23
5.2.130.0020.0369.19
5.2.120.0060.0309.19
5.2.110.0060.0309.19
5.2.100.0070.0279.19
5.2.90.0080.0309.19
5.2.80.0070.0339.18
5.2.70.0040.0319.19
5.2.60.0040.0379.14
5.2.50.0070.0279.12
5.2.40.0070.0269.09
5.2.30.0060.0349.06
5.2.20.0050.0319.05
5.2.10.0070.0278.96
5.2.00.0070.0368.82
5.1.60.0020.0268.11
5.1.50.0080.0298.10
5.1.40.0080.0318.08
5.1.30.0080.0238.43
5.1.20.0040.0408.45
5.1.10.0040.0288.18
5.1.00.0020.0278.18
5.0.50.0060.0226.65
5.0.40.0050.0196.52
5.0.30.0040.0366.32
5.0.20.0020.0246.29
5.0.10.0030.0216.27
5.0.00.0030.0306.27
4.4.90.0020.0224.78
4.4.80.0060.0174.76
4.4.70.0030.0154.75
4.4.60.0020.0164.75
4.4.50.0030.0164.77
4.4.40.0020.0284.71
4.4.30.0070.0204.76
4.4.20.0040.0154.85
4.4.10.0030.0174.85
4.4.00.0010.0314.76
4.3.110.0020.0164.67
4.3.100.0050.0154.66
4.3.90.0020.0184.63
4.3.80.0020.0324.58
4.3.70.0030.0154.63
4.3.60.0030.0144.63
4.3.50.0030.0154.63
4.3.40.0050.0234.54
4.3.30.0060.0183.31
4.3.20.0020.0223.29
4.3.10.0030.0153.25
4.3.00.0030.0206.86

preferences:
43.12 ms | 401 KiB | 5 Q