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.0060.00918.68
8.3.50.0070.01321.16
8.3.40.0040.01118.89
8.3.30.0040.01119.21
8.3.20.0030.00620.29
8.3.10.0040.00420.53
8.3.00.0040.00419.38
8.2.180.0090.00916.73
8.2.170.0150.00022.96
8.2.160.0030.01018.98
8.2.150.0050.00324.18
8.2.140.0000.00824.66
8.2.130.0040.00426.16
8.2.120.0000.00722.24
8.2.110.0000.01022.08
8.2.100.0090.00318.09
8.2.90.0060.00319.20
8.2.80.0050.00317.97
8.2.70.0000.00917.75
8.2.60.0050.00317.93
8.2.50.0040.00718.07
8.2.40.0000.00818.09
8.2.30.0000.00719.27
8.2.20.0080.00017.94
8.2.10.0040.00418.01
8.2.00.0040.00417.89
8.1.280.0130.00725.92
8.1.270.0060.00323.91
8.1.260.0000.00726.35
8.1.250.0040.00428.09
8.1.240.0030.00723.87
8.1.230.0080.00419.25
8.1.220.0040.00417.91
8.1.210.0040.00418.77
8.1.200.0060.00617.47
8.1.190.0050.00317.48
8.1.180.0030.00518.10
8.1.170.0090.00018.74
8.1.160.0040.00422.10
8.1.150.0000.00719.01
8.1.140.0020.00517.53
8.1.130.0030.00317.86
8.1.120.0040.00417.54
8.1.110.0070.00017.60
8.1.100.0030.00517.53
8.1.90.0000.00717.57
8.1.80.0050.00317.57
8.1.70.0000.00717.51
8.1.60.0040.00417.59
8.1.50.0030.00517.52
8.1.40.0000.00717.52
8.1.30.0000.00817.61
8.1.20.0000.00917.68
8.1.10.0070.00017.66
8.1.00.0040.00417.54
8.0.300.0020.00518.77
8.0.290.0040.00417.00
8.0.280.0000.00718.43
8.0.270.0000.00717.44
8.0.260.0000.00617.32
8.0.250.0070.00017.08
8.0.240.0000.00717.00
8.0.230.0030.00317.11
8.0.220.0070.00017.07
8.0.210.0000.00717.01
8.0.200.0030.00317.04
8.0.190.0000.00817.14
8.0.180.0070.00016.97
8.0.170.0000.00816.96
8.0.160.0040.00416.96
8.0.150.0000.00717.01
8.0.140.0030.00517.01
8.0.130.0060.00013.41
8.0.120.0000.00816.98
8.0.110.0000.00716.90
8.0.100.0040.00416.91
8.0.90.0000.00716.93
8.0.80.0080.00817.02
8.0.70.0040.00417.03
8.0.60.0030.00517.08
8.0.50.0000.00716.85
8.0.30.0090.01117.13
8.0.20.0140.01017.40
8.0.10.0000.00817.05
8.0.00.0110.01116.91
7.4.330.0020.00215.20
7.4.320.0000.00616.59
7.4.300.0000.00616.58
7.4.290.0000.00716.58
7.4.280.0040.00716.71
7.4.270.0000.00716.60
7.4.260.0040.00416.55
7.4.250.0040.00416.62
7.4.240.0040.00416.56
7.4.230.0030.00316.57
7.4.220.0100.01016.47
7.4.210.0140.00016.63
7.4.200.0050.00316.67
7.4.160.0090.01216.54
7.4.150.0070.01117.40
7.4.140.0090.00817.86
7.4.130.0160.00316.53
7.4.120.0070.01016.55
7.4.110.0030.01316.63
7.4.100.0150.00316.64
7.4.90.0090.01516.73
7.4.80.0030.01319.39
7.4.70.0000.01616.78
7.4.60.0120.00416.72
7.4.50.0030.00616.78
7.4.40.0120.00416.46
7.4.30.0060.01516.68
7.4.00.0070.01015.19
7.3.330.0060.00013.46
7.3.320.0030.00313.34
7.3.310.0030.00316.37
7.3.300.0000.00716.34
7.3.290.0090.00616.45
7.3.280.0090.00916.45
7.3.270.0040.01517.40
7.3.260.0050.01616.57
7.3.250.0060.01416.67
7.3.240.0100.00716.43
7.3.230.0030.01416.63
7.3.210.0060.01216.42
7.3.200.0070.01116.70
7.3.190.0130.00416.43
7.3.180.0170.00616.71
7.3.170.0080.00816.69
7.3.160.0110.00616.48
7.3.120.0030.01514.79
7.3.110.0090.00614.82
7.3.100.0120.00614.80
7.3.90.0100.00615.16
7.3.80.0030.01014.88
7.3.70.0060.00614.77
7.3.60.0000.01414.93
7.3.50.0090.00615.00
7.3.40.0030.01014.89
7.3.30.0040.00814.87
7.3.20.0090.00316.65
7.3.10.0060.00616.66
7.3.00.0100.00316.42
7.2.330.0170.00016.77
7.2.320.0190.00316.79
7.2.310.0090.01216.87
7.2.300.0090.00916.83
7.2.290.0140.00416.52
7.2.250.0040.01515.25
7.2.240.0110.00715.22
7.2.230.0090.00615.26
7.2.220.0030.01014.89
7.2.210.0100.00314.84
7.2.200.0070.00715.30
7.2.190.0000.01215.06
7.2.180.0070.00715.17
7.2.170.0140.00014.92
7.2.160.0060.00915.00
7.2.150.0100.00317.00
7.2.140.0120.00316.91
7.2.130.0100.00317.02
7.2.120.0050.00516.92
7.2.110.0140.00016.93
7.2.100.0030.01317.07
7.2.90.0090.00617.01
7.2.80.0090.00616.78
7.2.70.0090.00616.72
7.2.60.0030.01616.98
7.2.50.0090.00616.80
7.2.40.0100.00316.80
7.2.30.0070.00317.00
7.2.20.0070.00717.09
7.2.10.0090.00916.86
7.2.00.0050.01018.19
7.1.330.0030.01315.65
7.1.320.0000.01516.00
7.1.310.0070.00715.70
7.1.300.0070.01016.00
7.1.290.0100.00615.77
7.1.280.0090.00015.82
7.1.270.0030.01015.82
7.1.260.0030.01315.91
7.1.250.0040.01115.67
7.1.240.0000.01215.86
7.1.230.0070.01015.65
7.1.220.0040.01115.63
7.1.210.0080.00815.85
7.1.200.0060.01015.63
7.1.190.0050.00515.92
7.1.180.0000.01015.92
7.1.170.0070.00715.94
7.1.160.0030.01015.66
7.1.150.0070.00715.53
7.1.140.0070.00715.96
7.1.130.0060.00915.62
7.1.120.0070.00315.84
7.1.110.0040.01115.89
7.1.100.0120.00617.02
7.1.90.0060.00915.74
7.1.80.0040.01215.60
7.1.70.0050.00816.47
7.1.60.0050.01417.64
7.1.50.0030.01616.49
7.1.40.0090.00615.78
7.1.30.0040.00815.83
7.1.20.0090.00615.87
7.1.10.0040.00715.79
7.1.00.0080.04219.02
7.0.330.0070.00715.36
7.0.320.0060.00615.60
7.0.310.0100.00715.54
7.0.300.0110.00415.37
7.0.290.0000.01415.43
7.0.280.0000.01015.43
7.0.270.0110.00415.15
7.0.260.0070.00315.67
7.0.250.0060.01015.51
7.0.240.0110.00415.49
7.0.230.0040.01115.37
7.0.220.0070.00715.33
7.0.210.0130.00015.48
7.0.200.0060.00615.95
7.0.190.0110.00315.26
7.0.180.0000.01315.36
7.0.170.0030.01015.38
7.0.160.0040.00415.46
7.0.150.0100.00315.14
7.0.140.0030.04218.57
7.0.130.0030.01015.50
7.0.120.0070.00715.52
7.0.110.0030.01015.31
7.0.100.0040.00415.48
7.0.90.0000.00815.52
7.0.80.0070.00715.41
7.0.70.0000.01415.51
7.0.60.0070.04317.74
7.0.50.0030.04316.78
7.0.40.0080.02816.94
7.0.30.0170.04316.73
7.0.20.0200.04316.92
7.0.10.0030.05016.87
7.0.00.0030.02816.75
5.6.400.0080.00614.31
5.6.390.0000.01314.65
5.6.380.0130.00014.45
5.6.370.0120.00314.14
5.6.360.0030.00614.69
5.6.350.0090.00614.59
5.6.340.0100.00014.42
5.6.330.0080.00414.37
5.6.320.0110.00714.50
5.6.310.0030.01214.60
5.6.300.0090.00614.60
5.6.290.0000.01014.27
5.6.280.0080.03817.98
5.6.270.0080.00814.60
5.6.260.0060.00914.56
5.6.250.0030.01014.66
5.6.240.0100.00014.36
5.6.230.0110.00514.36
5.6.220.0070.01114.64
5.6.210.0050.02417.60
5.6.200.0120.04316.23
5.6.190.0030.04517.59
5.6.180.0180.02317.56
5.6.170.0090.02917.44
5.6.160.0050.02517.44
5.6.150.0100.04116.26
5.6.140.0070.02516.28
5.6.130.0070.03816.18
5.6.120.0090.04217.64
5.6.110.0070.04117.74
5.6.100.0080.04117.73
5.6.90.0070.04518.00
5.6.80.0080.03217.33
5.6.70.0130.00314.26
5.6.60.0120.00314.22
5.6.50.0100.00314.26
5.6.40.0030.01314.32
5.6.30.0030.00614.07
5.6.20.0000.01514.33
5.6.10.0040.00814.39
5.6.00.0000.01314.61
5.5.380.0030.01114.43
5.5.370.0000.01514.49
5.5.360.0060.01314.39
5.5.350.0140.02417.53
5.5.340.0080.02516.24
5.5.330.0080.04217.35
5.5.320.0170.02517.40
5.5.310.0150.04717.40
5.5.300.0090.02916.30
5.5.290.0100.03816.21
5.5.280.0040.02517.61
5.5.270.0060.03217.71
5.5.260.0070.04517.63
5.5.250.0170.03717.46
5.5.240.0050.04417.32
5.5.230.0070.00714.53
5.5.220.0040.01114.65
5.5.210.0040.00714.27
5.5.200.0090.00614.53
5.5.190.0070.00714.55
5.5.180.0090.00314.50
5.5.170.0000.01114.66
5.5.160.0060.00614.52
5.5.150.0100.00713.98
5.5.140.0060.00614.44
5.5.130.0140.00314.22
5.5.120.0080.00414.34
5.5.110.0090.00613.93
5.5.100.0030.01014.64
5.5.90.0110.00614.16
5.5.80.0040.01114.41
5.5.70.0100.00314.48
5.5.60.0040.01114.51
5.5.50.0030.00914.58
5.5.40.0110.00014.64
5.5.30.0030.01514.16
5.5.20.0070.01014.74
5.5.10.0100.00713.87
5.5.00.0060.00614.58
5.4.450.0170.03715.64
5.4.440.0550.02715.64
5.4.430.0400.03315.59
5.4.420.0580.03515.70
5.4.410.0490.03415.50
5.4.400.0450.03515.34
5.4.390.0390.03515.54
5.4.380.0230.03315.22
5.4.370.0150.03815.21
5.4.360.0200.04115.29
5.4.350.0130.03315.28
5.4.340.0220.02315.14
5.4.330.0030.00311.80
5.4.320.0060.02212.16
5.4.310.0020.02312.16
5.4.300.0070.02112.16
5.4.290.0040.02512.16
5.4.280.0040.02212.11
5.4.270.0060.01812.11
5.4.260.0050.02412.11
5.4.250.0060.02312.11
5.4.240.0050.02312.11
5.4.230.0070.02412.11
5.4.220.0080.02012.11
5.4.210.0070.01912.11
5.4.200.0030.03012.11
5.4.190.0060.02012.11
5.4.180.0060.02512.10
5.4.170.0040.02312.11
5.4.160.0040.02212.11
5.4.150.0030.02612.11
5.4.140.0040.02411.95
5.4.130.0060.02111.94
5.4.120.0050.02011.92
5.4.110.0040.02111.92
5.4.100.0070.02111.92
5.4.90.0060.02211.92
5.4.80.0030.02511.92
5.4.70.0080.02011.92
5.4.60.0040.02311.92
5.4.50.0030.02211.91
5.4.40.0050.02311.91
5.4.30.0060.01911.91
5.4.20.0050.02011.91
5.4.10.0060.02511.91
5.4.00.0060.02111.65
5.3.290.0060.03912.80
5.3.280.0070.04112.71
5.3.270.0090.04212.72
5.3.260.0060.03812.73
5.3.250.0070.03612.73
5.3.240.0100.04212.73
5.3.230.0080.04212.72
5.3.220.0070.03612.70
5.3.210.0120.03512.70
5.3.200.0060.04212.70
5.3.190.0100.03412.70
5.3.180.0090.03312.70
5.3.170.0080.04912.69
5.3.160.0100.05312.70
5.3.150.0060.03612.70
5.3.140.0070.03612.68
5.3.130.0070.04012.67
5.3.120.0100.03912.68
5.3.110.0070.04012.68
5.3.100.0060.04312.16
5.3.90.0050.03712.14
5.3.80.0060.04112.14
5.3.70.0060.03612.13
5.3.60.0030.04712.12
5.3.50.0040.04812.06
5.3.40.0060.04312.06
5.3.30.0090.03112.02
5.3.20.0070.03411.80
5.3.10.0080.03711.77
5.3.00.0060.03811.75
5.2.170.0050.0319.24
5.2.160.0020.0339.23
5.2.150.0070.0349.24
5.2.140.0050.0309.23
5.2.130.0050.0299.19
5.2.120.0090.0269.19
5.2.110.0040.0309.20
5.2.100.0050.0279.19
5.2.90.0070.0279.19
5.2.80.0050.0329.18
5.2.70.0060.0389.19
5.2.60.0100.0319.15
5.2.50.0040.0339.11
5.2.40.0060.0309.09
5.2.30.0060.0509.06
5.2.20.0040.0329.05
5.2.10.0050.0278.96
5.2.00.0070.0308.82
5.1.60.0050.0288.11
5.1.50.0060.0238.10
5.1.40.0030.0358.08
5.1.30.0030.0308.43
5.1.20.0050.0258.45
5.1.10.0030.0328.18
5.1.00.0030.0278.18
5.0.50.0040.0206.66
5.0.40.0020.0216.52
5.0.30.0030.0326.32
5.0.20.0040.0206.29
5.0.10.0030.0286.28
5.0.00.0020.0366.27
4.4.90.0040.0154.78
4.4.80.0050.0134.75
4.4.70.0030.0154.76
4.4.60.0040.0144.76
4.4.50.0020.0154.77
4.4.40.0020.0254.71
4.4.30.0030.0154.75
4.4.20.0040.0144.85
4.4.10.0030.0164.85
4.4.00.0050.0244.76
4.3.110.0040.0164.67
4.3.100.0040.0134.66
4.3.90.0030.0144.64
4.3.80.0030.0334.58
4.3.70.0030.0154.63
4.3.60.0060.0204.63
4.3.50.0040.0214.63
4.3.40.0040.0294.54
4.3.30.0030.0163.31
4.3.20.0010.0183.29
4.3.10.0020.0153.25
4.3.00.0030.0236.86

preferences:
48.65 ms | 401 KiB | 5 Q