3v4l.org

run code in 300+ PHP versions simultaneously
<?php $names = ['Alice', 'Bob', 'Charlie', 'Alice', 'Dave', 'Alice']; class Name { public $name; public $id; public function __construct($name, $id = 0) { $this->name = $name; $this->id = $id; } } function is_similar($a, $b) { return $a->name == $b->name; } function contains(array $list, $item, callable $comparitor) { foreach ($list as $test) { if ($comparitor) { return true; } } return false; } function partial($func, $arg1) { $func_args = func_get_args(); $args = array_slice($func_args, 1); return function() use($func, $args) { $full_args = array_merge($args, func_get_args()); return call_user_func_array($func, $full_args); }; } // Transform strings -> objects $mappedNames = array_map(function($name) { return new Name($name); }, $names); // Deduplicate list $reduction = function(callable $comparitor, array $carry, $item) { if (contains($carry, $item, $comparitor)) { return $carry; } return array_merge($carry, array($item)); }; $reducedNames = array_reduce($mappedNames, partial($reduction, "is_similar"), []); $idNames = array_map(function($item, $id) { return new Name($item->name, $id); }, $reducedNames, range(1, count($reducedNames))); var_dump($idNames);

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.0070.01116.50
8.3.50.0070.00922.06
8.3.40.0110.00418.93
8.3.30.0140.00319.17
8.3.20.0070.00020.34
8.3.10.0050.00323.54
8.3.00.0090.00019.13
8.2.180.0210.00016.88
8.2.170.0090.00622.96
8.2.160.0070.01020.22
8.2.150.0040.00424.18
8.2.140.0080.00024.66
8.2.130.0000.00826.16
8.2.120.0040.00421.00
8.2.110.0030.00620.35
8.2.100.0060.00617.74
8.2.90.0000.00819.35
8.2.80.0030.00517.97
8.2.70.0030.00617.50
8.2.60.0060.00318.03
8.2.50.0030.00618.07
8.2.40.0000.00919.83
8.2.30.0000.00918.09
8.2.20.0000.00817.71
8.2.10.0060.00318.02
8.2.00.0070.00317.75
8.1.280.0110.00425.92
8.1.270.0080.00023.87
8.1.260.0060.00326.35
8.1.250.0040.00428.09
8.1.240.0000.01123.97
8.1.230.0080.00417.42
8.1.220.0060.00317.74
8.1.210.0040.00418.77
8.1.200.0000.01017.36
8.1.190.0000.00817.53
8.1.180.0100.00018.10
8.1.170.0080.00018.66
8.1.160.0000.00821.95
8.1.150.0070.00018.71
8.1.140.0000.00717.38
8.1.130.0070.00017.84
8.1.120.0040.00417.57
8.1.110.0070.00017.50
8.1.100.0000.00717.33
8.1.90.0000.00817.52
8.1.80.0070.00017.44
8.1.70.0000.00717.43
8.1.60.0050.00517.52
8.1.50.0050.00317.55
8.1.40.0020.00517.54
8.1.30.0040.00417.65
8.1.20.0050.00217.72
8.1.10.0040.00417.54
8.1.00.0000.00817.52
8.0.300.0070.00018.77
8.0.290.0040.00416.88
8.0.280.0000.00718.58
8.0.270.0000.00717.25
8.0.260.0030.00517.32
8.0.250.0070.00016.95
8.0.240.0000.00716.91
8.0.230.0040.00417.04
8.0.220.0070.00016.86
8.0.210.0030.00316.86
8.0.200.0000.00716.93
8.0.190.0040.00417.11
8.0.180.0030.00517.02
8.0.170.0000.00816.97
8.0.160.0040.00417.03
8.0.150.0080.00016.96
8.0.140.0040.00416.86
8.0.130.0070.00013.41
8.0.120.0040.00416.82
8.0.110.0050.00316.93
8.0.100.0040.00416.93
8.0.90.0030.00516.87
8.0.80.0030.01216.95
8.0.70.0030.00516.78
8.0.60.0050.00216.94
8.0.50.0000.00716.91
8.0.30.0050.01417.09
8.0.20.0090.01017.43
8.0.10.0000.00816.92
8.0.00.0090.00816.75
7.4.330.0030.00315.00
7.4.320.0000.00716.67
7.4.300.0060.00016.66
7.4.290.0070.00016.63
7.4.280.0040.00416.61
7.4.270.0000.00816.50
7.4.260.0050.00216.53
7.4.250.0040.00416.54
7.4.240.0020.00616.52
7.4.230.0000.00716.36
7.4.220.0150.00316.59
7.4.210.0060.00916.56
7.4.200.0000.00716.41
7.4.190.0040.00416.67
7.4.160.0060.00916.65
7.4.150.0030.01517.40
7.4.140.0080.00917.86
7.4.130.0070.01116.58
7.4.120.0050.01316.45
7.4.110.0070.01116.47
7.4.100.0060.01216.43
7.4.90.0130.01016.43
7.4.80.0070.01019.39
7.4.70.0060.00916.69
7.4.60.0100.00716.62
7.4.50.0000.00916.62
7.4.40.0070.01122.77
7.4.30.0110.00716.52
7.4.00.0060.00914.94
7.3.330.0050.00013.36
7.3.320.0000.00613.33
7.3.310.0080.00016.39
7.3.300.0030.00316.36
7.3.290.0070.01016.40
7.3.280.0080.01016.34
7.3.270.0090.01517.40
7.3.260.0100.01316.37
7.3.250.0090.00916.49
7.3.240.0120.00916.64
7.3.230.0120.00416.59
7.3.210.0060.01116.55
7.3.200.0100.00719.39
7.3.190.0030.01916.56
7.3.180.0040.01216.71
7.3.170.0090.00616.56
7.3.160.0040.01216.46
7.3.120.0090.00815.03
7.3.110.0080.00814.60
7.3.100.0000.02014.89
7.3.90.0060.01214.95
7.3.80.0070.00714.79
7.3.70.0030.01314.63
7.3.60.0000.01214.83
7.3.50.0000.01515.05
7.3.40.0040.01114.71
7.3.30.0070.00714.93
7.3.20.0090.00616.85
7.3.10.0060.00616.46
7.3.00.0140.00016.72
7.2.330.0120.01216.77
7.2.320.0060.01116.84
7.2.310.0110.00516.84
7.2.300.0080.00816.73
7.2.290.0060.01516.80
7.2.250.0030.01715.35
7.2.240.0100.01015.00
7.2.230.0100.00615.03
7.2.220.0030.01515.26
7.2.210.0000.01614.96
7.2.200.0030.00915.32
7.2.190.0000.01915.05
7.2.180.0030.00615.23
7.2.170.0130.00014.76
7.2.160.0140.00415.11
7.2.150.0060.01016.70
7.2.140.0120.00317.04
7.2.130.0070.01117.06
7.2.120.0160.00016.69
7.2.110.0040.01117.08
7.2.100.0070.01016.69
7.2.90.0100.01017.19
7.2.80.0130.00617.20
7.2.70.0090.00616.96
7.2.60.0040.01116.87
7.2.50.0120.00616.98
7.2.40.0070.00716.99
7.2.30.0000.01316.93
7.2.20.0000.01416.91
7.2.10.0100.00016.66
7.2.00.0140.00318.27
7.1.330.0070.01015.55
7.1.320.0100.00715.87
7.1.310.0000.01515.84
7.1.300.0040.01115.80
7.1.290.0040.00715.78
7.1.280.0060.00915.93
7.1.270.0070.01015.82
7.1.260.0100.00015.54
7.1.250.0070.00715.73
7.1.240.0040.01115.79
7.1.230.0060.00315.59
7.1.220.0030.00615.88
7.1.210.0070.00715.96
7.1.200.0090.00915.54
7.1.190.0090.00615.80
7.1.180.0030.00915.90
7.1.170.0060.00915.75
7.1.160.0120.00015.77
7.1.150.0060.01115.52
7.1.140.0120.00315.91
7.1.130.0060.00615.81
7.1.120.0090.00015.84
7.1.110.0080.00415.71
7.1.100.0310.00516.08
7.1.90.0030.01015.99
7.1.80.0000.01016.05
7.1.70.0050.01016.48
7.1.60.0040.01417.68
7.1.50.0130.00825.23
7.1.40.0110.00415.78
7.1.30.0080.00415.64
7.1.20.0030.01015.61
7.1.10.0040.01115.93
7.1.00.0020.04419.14
7.0.330.0070.00315.34
7.0.320.0040.00415.19
7.0.310.0120.00615.41
7.0.300.0030.01415.37
7.0.290.0030.00915.43
7.0.280.0030.01015.52
7.0.270.0030.00915.41
7.0.260.0090.00315.46
7.0.250.0080.00615.61
7.0.240.0080.00315.34
7.0.230.0030.01015.40
7.0.220.0030.01015.11
7.0.210.0030.01015.61
7.0.200.0000.00916.22
7.0.190.0030.01015.45
7.0.180.0100.00315.40
7.0.170.0100.00315.62
7.0.160.0030.00615.39
7.0.150.0040.01115.56
7.0.140.0050.03718.73
7.0.130.0030.00915.40
7.0.120.0030.01015.57
7.0.110.0130.00315.50
7.0.100.0000.01715.63
7.0.90.0000.01215.46
7.0.80.0000.01015.45
7.0.70.0000.01515.50
7.0.60.0030.04017.54
7.0.50.0060.03716.79
7.0.40.0080.04716.79
7.0.30.0300.03716.95
7.0.20.0140.03117.00
7.0.10.0050.04316.86
7.0.00.0020.05416.84
5.6.400.0090.00914.45
5.6.390.0000.01114.47
5.6.380.0080.00814.41
5.6.370.0090.00314.35
5.6.360.0030.01314.49
5.6.350.0100.00614.35
5.6.340.0040.00814.72
5.6.330.0140.00014.69
5.6.320.0030.01014.42
5.6.310.0060.00914.73
5.6.300.0040.01114.29
5.6.290.0000.01014.66
5.6.280.0080.03517.79
5.6.270.0070.00714.33
5.6.260.0060.01214.33
5.6.250.0040.01114.32
5.6.240.0070.00714.50
5.6.230.0070.00714.46
5.6.220.0100.01014.43
5.6.210.0100.03817.37
5.6.200.0070.04816.38
5.6.190.0050.03717.35
5.6.180.0180.04417.60
5.6.170.0120.02917.49
5.6.160.0100.04217.40
5.6.150.0030.05116.26
5.6.140.0120.02516.35
5.6.130.0020.03516.31
5.6.120.0050.04917.71
5.6.110.0110.04417.74
5.6.100.0080.04817.67
5.6.90.0030.02717.75
5.6.80.0080.03217.49
5.6.70.0030.00914.19
5.6.60.0040.00714.62
5.6.50.0100.00414.23
5.6.40.0030.00914.22
5.6.30.0090.00314.39
5.6.20.0100.00314.34
5.6.10.0100.00314.26
5.6.00.0080.00514.41
5.5.380.0040.00814.09
5.5.370.0030.00914.54
5.5.360.0000.01514.62
5.5.350.0100.03517.48
5.5.340.0040.03916.24
5.5.330.0080.03717.45
5.5.320.0150.03917.26
5.5.310.0200.04717.46
5.5.300.0020.05016.13
5.5.290.0050.03316.24
5.5.280.0120.04217.54
5.5.270.0030.05217.72
5.5.260.0120.04017.43
5.5.250.0110.04117.53
5.5.240.0170.04017.28
5.5.230.0030.01314.13
5.5.220.0090.00614.04
5.5.210.0080.00414.54
5.5.200.0060.00614.25
5.5.190.0080.00414.39
5.5.180.0030.01314.13
5.5.170.0000.00914.46
5.5.160.0100.00314.47
5.5.150.0000.01614.29
5.5.140.0030.01014.48
5.5.130.0030.00914.16
5.5.120.0130.00014.47
5.5.110.0140.00314.50
5.5.100.0000.01014.46
5.5.90.0040.00814.50
5.5.80.0000.01614.51
5.5.70.0070.00714.47
5.5.60.0040.00714.36
5.5.50.0040.00714.03
5.5.40.0120.00014.04
5.5.30.0100.00314.26
5.5.20.0000.01414.33
5.5.10.0060.00313.77
5.5.00.0060.00314.03
5.4.450.0050.03815.87
5.4.440.0390.03415.93
5.4.430.0150.04315.72
5.4.420.0510.02815.79
5.4.410.0550.03515.66
5.4.400.0300.03415.71
5.4.390.0350.03115.75
5.4.380.0150.03115.52
5.4.370.0180.04315.54
5.4.360.0120.03915.51
5.4.350.0230.02815.45
5.4.340.0180.03115.45
5.4.330.0040.00412.28
5.4.320.0110.01912.40
5.4.310.0040.02512.40
5.4.300.0020.02612.40
5.4.290.0040.02612.40
5.4.280.0060.02512.33
5.4.270.0040.03212.34
5.4.260.0110.03812.33
5.4.250.0060.02912.33
5.4.240.0100.03512.34
5.4.230.0090.03412.33
5.4.220.0050.04012.33
5.4.210.0040.03512.33
5.4.200.0100.02212.33
5.4.190.0100.02812.33
5.4.180.0060.02612.33
5.4.170.0140.06212.33
5.4.160.0170.03912.33
5.4.150.0090.04612.33
5.4.140.0190.05312.17
5.4.130.0110.03812.17
5.4.120.0100.02912.15
5.4.110.0090.03112.14
5.4.100.0060.04212.14
5.4.90.0140.03512.14
5.4.80.0090.02812.14
5.4.70.0110.03812.14
5.4.60.0090.03212.14
5.4.50.0080.03212.14
5.4.40.0180.04312.13
5.4.30.0090.05512.13
5.4.20.0050.03812.13
5.4.10.0080.03412.13
5.4.00.0060.02211.88
5.3.290.0040.02612.54
5.3.280.0090.02012.50
5.3.270.0110.01812.50
5.3.260.0050.03012.50
5.3.250.0100.02412.50
5.3.240.0080.03512.50
5.3.230.0040.03612.49
5.3.220.0080.04012.48
5.3.210.0090.02912.48
5.3.200.0090.03012.48
5.3.190.0110.03212.48
5.3.180.0060.03112.47
5.3.170.0080.03012.47
5.3.160.0070.02312.47
5.3.150.0070.02312.48
5.3.140.0080.02312.47
5.3.130.0100.02212.47
5.3.120.0070.02512.47
5.3.110.0060.03212.47
5.3.100.0070.02512.20
5.3.90.0080.03512.18
5.3.80.0020.02612.18
5.3.70.0030.02712.18
5.3.60.0080.02112.17
5.3.50.0060.02512.14
5.3.40.0030.02512.14
5.3.30.0060.01912.11
5.3.20.0080.02511.99
5.3.10.0090.02811.97
5.3.00.0090.02011.97
5.2.170.0090.0349.15
5.2.160.0070.0379.15
5.2.150.0070.0459.15
5.2.140.0120.0399.14
5.2.130.0040.0409.12
5.2.120.0180.0539.11
5.2.110.0100.0519.11
5.2.100.0080.0409.11
5.2.90.0130.0379.11
5.2.80.0050.0339.11
5.2.70.0100.0409.11
5.2.60.0070.0439.06
5.2.50.0100.0409.03
5.2.40.0090.0439.00
5.2.30.0080.0408.99
5.2.20.0090.0348.97
5.2.10.0080.0338.91
5.2.00.0040.0348.76
5.1.60.0040.0278.05
5.1.50.0080.0278.05
5.1.40.0040.0288.03
5.1.30.0060.0348.38
5.1.20.0050.0308.40
5.1.10.0070.0348.13
5.1.00.0070.0278.13
5.0.50.0070.0286.60
5.0.40.0030.0226.46
5.0.30.0040.0326.27
5.0.20.0060.0306.25
5.0.10.0090.0296.22
5.0.00.0120.0356.21
4.4.90.0050.0254.78
4.4.80.0080.0214.75
4.4.70.0060.0254.75
4.4.60.0090.0194.75
4.4.50.0130.0394.77
4.4.40.0080.0344.71
4.4.30.0040.0284.76
4.4.20.0070.0254.84
4.4.10.0040.0244.85
4.4.00.0030.0334.76
4.3.110.0040.0174.67
4.3.100.0050.0134.66
4.3.90.0040.0134.63
4.3.80.0040.0244.59
4.3.70.0020.0164.63
4.3.60.0030.0154.63
4.3.50.0050.0224.63
4.3.40.0030.0274.54
4.3.30.0030.0173.27
4.3.20.0040.0163.25
4.3.10.0030.0223.22
4.3.00.0000.02013.47

preferences:
42.54 ms | 401 KiB | 5 Q