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);die(); $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.0110.00318.68
8.3.50.0080.01221.28
8.3.40.0040.01118.84
8.3.30.0140.00719.09
8.3.20.0040.00420.34
8.3.10.0050.00320.51
8.3.00.0080.00019.22
8.2.180.0090.00616.50
8.2.170.0110.00422.96
8.2.160.0070.00720.66
8.2.150.0100.00024.18
8.2.140.0050.00324.66
8.2.130.0040.00426.16
8.2.120.0070.00019.83
8.2.110.0030.00622.25
8.2.100.0080.00317.84
8.2.90.0000.00719.30
8.2.80.0000.00817.97
8.2.70.0030.00617.48
8.2.60.0080.00017.92
8.2.50.0080.00418.07
8.2.40.0030.00518.20
8.2.30.0000.00719.45
8.2.20.0030.00517.90
8.2.10.0050.00318.21
8.2.00.0040.00417.93
8.1.280.0130.00725.92
8.1.270.0000.00823.85
8.1.260.0000.00826.35
8.1.250.0070.00028.09
8.1.240.0100.00023.83
8.1.230.0030.00719.29
8.1.220.0000.00817.79
8.1.210.0020.00518.77
8.1.200.0060.00317.38
8.1.190.0000.00817.36
8.1.180.0000.00818.10
8.1.170.0030.00618.69
8.1.160.0040.00422.16
8.1.150.0000.00718.96
8.1.140.0040.00417.45
8.1.130.0030.00317.89
8.1.120.0000.00717.46
8.1.110.0050.00317.39
8.1.100.0030.00617.41
8.1.90.0000.00817.42
8.1.80.0040.00717.40
8.1.70.0040.00417.54
8.1.60.0040.00417.55
8.1.50.0030.00517.58
8.1.40.0040.00417.63
8.1.30.0050.00317.71
8.1.20.0000.00817.78
8.1.10.0000.00717.66
8.1.00.0000.00817.57
8.0.300.0000.00718.77
8.0.290.0000.00716.88
8.0.280.0030.00318.59
8.0.270.0000.00717.34
8.0.260.0030.00317.27
8.0.250.0000.00717.10
8.0.240.0000.00717.00
8.0.230.0070.00017.15
8.0.220.0040.00416.94
8.0.210.0030.00317.08
8.0.200.0030.00317.05
8.0.190.0000.00817.11
8.0.180.0000.00817.11
8.0.170.0030.00617.09
8.0.160.0030.00517.09
8.0.150.0030.00516.84
8.0.140.0000.00716.98
8.0.130.0030.00313.38
8.0.120.0040.00416.89
8.0.110.0040.00417.04
8.0.100.0080.00017.03
8.0.90.0000.00717.02
8.0.80.0100.00717.07
8.0.70.0040.00417.00
8.0.60.0000.00716.89
8.0.50.0050.00217.06
8.0.30.0090.01017.18
8.0.20.0080.01017.40
8.0.10.0080.00017.04
8.0.00.0050.01316.95
7.4.330.0000.00515.14
7.4.320.0060.00016.59
7.4.300.0060.00016.68
7.4.290.0040.00416.58
7.4.280.0030.00616.64
7.4.270.0070.00016.57
7.4.260.0000.00716.65
7.4.250.0040.00416.50
7.4.240.0040.00416.61
7.4.230.0040.00416.67
7.4.220.0060.01416.51
7.4.210.0040.01116.60
7.4.200.0070.00016.69
7.4.160.0120.01216.75
7.4.150.0130.00717.40
7.4.140.0080.00917.86
7.4.130.0080.01116.67
7.4.120.0120.00616.54
7.4.110.0080.00816.39
7.4.100.0150.00616.72
7.4.90.0080.01116.76
7.4.80.0170.00616.72
7.4.70.0060.01016.54
7.4.60.0070.01616.73
7.4.50.0000.00816.48
7.4.40.0100.00716.36
7.4.30.0070.01016.65
7.4.00.0060.01215.07
7.3.330.0000.00513.39
7.3.320.0000.00513.33
7.3.310.0050.00316.36
7.3.300.0000.00716.34
7.3.290.0060.01316.39
7.3.280.0060.00916.42
7.3.270.0150.00317.40
7.3.260.0150.00916.41
7.3.250.0130.00816.50
7.3.240.0110.00716.61
7.3.230.0130.01016.47
7.3.210.0110.00716.43
7.3.200.0070.00919.39
7.3.190.0180.00316.63
7.3.180.0080.00816.56
7.3.170.0110.00516.59
7.3.160.0060.00916.36
7.3.120.0100.01014.75
7.3.110.0030.01614.66
7.3.100.0060.00915.09
7.3.90.0060.00914.86
7.3.80.0030.00614.97
7.3.70.0060.00614.67
7.3.60.0120.00614.63
7.3.50.0080.00314.95
7.3.40.0030.00914.98
7.3.30.0110.00414.88
7.3.20.0130.00316.72
7.3.10.0040.00716.63
7.3.00.0060.00616.59
7.2.330.0070.01016.49
7.2.320.0090.01316.81
7.2.310.0120.01516.59
7.2.300.0090.00916.83
7.2.290.0070.01116.81
7.2.250.0100.00615.03
7.2.240.0130.00315.30
7.2.230.0090.00614.85
7.2.220.0040.00714.91
7.2.210.0070.00715.08
7.2.200.0060.01215.32
7.2.190.0090.00315.25
7.2.180.0050.00515.14
7.2.170.0090.00615.01
7.2.130.0110.00717.00
7.2.120.0110.00316.93
7.2.110.0030.01316.96
7.2.100.0040.01117.06
7.2.90.0130.00017.09
7.2.80.0000.01517.06
7.2.70.0050.00916.65
7.2.60.0100.00317.07
7.2.50.0000.00917.16
7.2.40.0090.00616.87
7.2.30.0060.00916.83
7.2.20.0070.00316.93
7.2.10.0060.00616.98
7.2.00.0030.01118.27
7.1.330.0070.00715.86
7.1.320.0090.00315.91
7.1.310.0040.01215.90
7.1.300.0080.00415.89
7.1.290.0040.00715.84
7.1.280.0090.00315.78
7.1.270.0040.01215.91
7.1.260.0030.01315.65
7.1.250.0030.01015.54
7.1.200.0100.00315.68
7.1.100.0120.01218.28
7.1.70.0040.00417.26
7.1.60.0140.01019.32
7.1.50.0030.02116.69
7.1.00.0030.07722.32
7.0.200.0030.00616.91
7.0.140.0100.06722.00
7.0.60.0000.05719.95
7.0.50.0030.04317.90
7.0.40.0030.04720.11
7.0.30.0300.07020.19
7.0.20.0200.08320.05
7.0.10.0170.07320.10
7.0.00.0100.08320.16
5.6.280.0030.07320.88
5.6.210.0030.04720.63
5.6.200.0100.07718.16
5.6.190.0070.08720.55
5.6.180.0370.03720.42
5.6.170.0470.05020.55
5.6.160.0070.08320.50
5.6.150.0030.04718.16
5.6.140.0100.07318.29
5.6.130.0100.08018.14
5.6.120.0070.08321.11
5.6.110.0070.04321.03
5.6.100.0170.05321.01
5.6.90.0100.09021.05
5.6.80.0030.08720.27
5.5.350.0200.07320.42
5.5.340.0030.05717.96
5.5.330.0070.05720.46
5.5.320.0430.02720.32
5.5.310.0230.04720.42
5.5.300.0070.06017.99
5.5.290.0030.08718.04
5.5.280.0030.08320.98
5.5.270.0030.07320.97
5.5.260.0130.07320.86
5.5.250.0130.07320.48
5.5.240.0130.06320.21
5.4.450.0330.05319.61
5.4.440.0570.06019.70
5.4.430.0970.06019.63
5.4.420.0870.05719.30
5.4.410.0030.06319.25
5.4.400.0870.05719.16
5.4.390.1070.05719.26
5.4.380.0470.05318.75
5.4.370.0400.05018.61
5.4.360.0270.05018.81
5.4.350.0330.05018.86
5.4.340.0430.04718.49
5.4.320.0070.03412.52
5.4.310.0050.03912.52
5.4.300.0080.03912.52
5.4.290.0040.04012.52
5.4.280.0030.03812.41
5.4.270.0060.03812.42
5.4.260.0060.03712.41
5.4.250.0070.03612.42
5.4.240.0040.03812.42
5.4.230.0040.03912.41
5.4.220.0090.03712.41
5.4.210.0070.03412.41
5.4.200.0050.04212.41
5.4.190.0060.04112.41
5.4.180.0070.04012.41
5.4.170.0070.03512.41
5.4.160.0080.04512.41
5.4.150.0070.04712.41
5.4.140.0030.04712.09
5.4.130.0110.03512.08
5.4.120.0060.03612.04
5.4.110.0080.04012.04
5.4.100.0060.03712.04
5.4.90.0090.03512.04
5.4.80.0020.05312.04
5.4.70.0070.03812.03
5.4.60.0050.03612.04
5.4.50.0090.03212.03
5.4.40.0080.03712.02
5.4.30.0060.03912.02
5.4.20.0050.03712.02
5.4.10.0050.03512.01
5.4.00.0040.03911.50
5.3.290.0060.03912.80
5.3.280.0060.03712.71
5.3.270.0040.04112.73
5.3.260.0070.03712.73
5.3.250.0040.04112.73
5.3.240.0090.03412.73
5.3.230.0050.03912.73
5.3.220.0040.03912.69
5.3.210.0090.04212.70
5.3.200.0090.03412.69
5.3.190.0070.03612.69
5.3.180.0060.03612.69
5.3.170.0070.03512.69
5.3.160.0060.03512.69
5.3.150.0070.03512.69
5.3.140.0040.03712.68
5.3.130.0080.03712.68
5.3.120.0090.03712.68
5.3.110.0060.04112.68
5.3.100.0060.04512.16
5.3.90.0060.03912.14
5.3.80.0080.04612.13
5.3.70.0040.04312.13
5.3.60.0060.04312.12
5.3.50.0070.03712.05
5.3.40.0080.03812.05
5.3.30.0060.03712.02
5.3.20.0080.03411.80
5.3.10.0040.04011.77
5.3.00.0080.03411.75
5.2.170.0050.0319.24
5.2.160.0040.0359.23
5.2.150.0060.0289.24
5.2.140.0040.0309.23
5.2.130.0040.0299.20
5.2.120.0060.0289.19
5.2.110.0040.0309.20
5.2.100.0060.0339.19
5.2.90.0050.0319.19
5.2.80.0040.0329.18
5.2.70.0040.0309.18
5.2.60.0050.0299.15
5.2.50.0080.0369.11
5.2.40.0080.0269.09
5.2.30.0060.0289.06
5.2.20.0060.0309.05
5.2.10.0030.0308.96
5.2.00.0040.0298.82
5.1.60.0060.0248.11
5.1.50.0070.0228.10
5.1.40.0020.0288.08
5.1.30.0060.0248.43
5.1.20.0070.0248.45
5.1.10.0030.0278.18
5.1.00.0050.0248.18
5.0.50.0010.0236.66
5.0.40.0050.0186.52
5.0.30.0050.0336.32
5.0.20.0030.0196.29
5.0.10.0060.0196.28
5.0.00.0030.0326.27
4.4.90.0040.0144.77
4.4.80.0050.0134.75
4.4.70.0050.0174.75
4.4.60.0020.0164.75
4.4.50.0010.0174.77
4.4.40.0040.0304.71
4.4.30.0040.0154.76
4.4.20.0010.0174.84
4.4.10.0030.0184.85
4.4.00.0030.0254.76
4.3.110.0030.0164.67
4.3.100.0040.0144.66
4.3.90.0040.0134.64
4.3.80.0010.0264.59
4.3.70.0040.0184.63
4.3.60.0040.0184.63
4.3.50.0050.0174.63
4.3.40.0020.0254.54
4.3.30.0010.0173.31
4.3.20.0010.0183.29
4.3.10.0050.0153.25
4.3.00.0030.0236.86

preferences:
42.98 ms | 401 KiB | 5 Q