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 contains(array $list, $item) { foreach ($list as $test) { if ($item->name == $test->name) { return true; } } return false; } // Transform strings -> objects $mappedNames = array_map(function($name) { return new Name($name); }, $names); // Deduplicate list $reducedNames = array_reduce($mappedNames, function($carry, $item) { if (contains($carry, $item)) { return $carry; } return array_merge($carry, array($item)); }, []); $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.40.0090.00618.85
8.3.30.0060.00818.96
8.3.20.0060.00320.16
8.3.10.0040.00423.49
8.3.00.0080.00019.25
8.2.170.0160.00622.96
8.2.160.0060.01020.44
8.2.150.0080.00024.18
8.2.140.0000.00824.66
8.2.130.0120.00026.16
8.2.120.0030.00622.12
8.2.110.0110.00322.25
8.2.100.0060.00617.97
8.2.90.0040.00419.34
8.2.80.0030.00517.97
8.2.70.0030.00517.63
8.2.60.0060.00317.93
8.2.50.0040.00418.07
8.2.40.0060.00319.96
8.2.30.0000.00818.07
8.2.20.0040.00417.76
8.2.10.0000.01018.02
8.2.00.0040.00717.76
8.1.270.0030.00523.98
8.1.260.0090.00026.35
8.1.250.0070.00028.09
8.1.240.0000.00923.56
8.1.230.0080.00319.22
8.1.220.0060.00317.77
8.1.210.0040.00418.77
8.1.200.0070.00317.35
8.1.190.0040.00417.66
8.1.180.0130.00018.10
8.1.170.0050.00318.61
8.1.160.0000.00722.13
8.1.150.0050.00318.57
8.1.140.0040.00417.38
8.1.130.0080.00017.80
8.1.120.0040.00417.41
8.1.110.0040.00417.50
8.1.100.0030.00417.37
8.1.90.0040.00417.51
8.1.80.0030.00317.46
8.1.70.0000.00717.37
8.1.60.0030.00517.60
8.1.50.0030.00617.51
8.1.40.0040.00417.52
8.1.30.0060.00317.55
8.1.20.0080.00017.69
8.1.10.0030.00617.59
8.1.00.0060.00317.41
8.0.300.0080.00020.67
8.0.290.0040.00417.05
8.0.280.0000.00718.45
8.0.270.0000.00817.17
8.0.260.0050.00317.28
8.0.250.0040.00416.96
8.0.240.0000.00717.01
8.0.230.0030.00516.88
8.0.220.0000.00716.93
8.0.210.0000.00716.93
8.0.200.0000.00617.03
8.0.190.0000.00716.96
8.0.180.0050.00216.94
8.0.170.0050.00316.93
8.0.160.0050.00316.89
8.0.150.0000.00716.95
8.0.140.0070.00016.85
8.0.130.0000.00613.34
8.0.120.0070.00016.95
8.0.110.0020.00516.81
8.0.100.0000.00716.75
8.0.90.0030.00516.87
8.0.80.0070.01116.84
8.0.70.0000.00716.74
8.0.60.0030.00516.91
8.0.50.0000.00717.01
8.0.30.0100.00916.99
8.0.20.0130.00617.40
8.0.10.0040.00417.06
8.0.00.0120.00616.68
7.4.330.0000.00515.00
7.4.320.0060.00016.61
7.4.300.0000.00616.61
7.4.290.0050.00316.52
7.4.280.0040.00416.55
7.4.270.0000.00716.60
7.4.260.0070.00016.50
7.4.250.0050.00316.38
7.4.240.0020.00616.58
7.4.230.0000.00816.41
7.4.220.0100.00716.54
7.4.210.0070.00916.62
7.4.200.0040.00416.38
7.4.190.0000.00716.74
7.4.160.0030.01316.35
7.4.150.0060.01217.40
7.4.140.0130.00517.86
7.4.130.0080.01316.52
7.4.120.0090.00916.52
7.4.110.0090.00916.51
7.4.100.0070.01016.64
7.4.90.0190.00616.40
7.4.80.0130.00319.39
7.4.70.0110.00616.60
7.4.60.0070.01516.37
7.4.50.0030.00616.41
7.4.40.0120.00822.77
7.4.30.0000.02016.38
7.4.10.0110.00815.25
7.4.00.0090.00714.93
7.3.330.0060.00013.20
7.3.320.0030.00313.30
7.3.310.0040.00416.43
7.3.300.0030.00316.37
7.3.290.0040.01216.42
7.3.280.0050.01116.35
7.3.270.0130.00317.40
7.3.260.0100.01016.52
7.3.250.0100.00716.56
7.3.240.0110.00916.34
7.3.230.0060.01216.64
7.3.210.0070.01116.54
7.3.200.0150.00819.39
7.3.190.0150.01816.43
7.3.180.0100.00616.46
7.3.170.0100.00716.48
7.3.160.0160.00016.54
7.3.130.0040.01414.83
7.3.120.0080.00914.72
7.3.110.0070.01014.66
7.3.100.0030.01414.81
7.3.90.0060.00614.92
7.3.80.0080.00814.74
7.3.70.0060.00814.77
7.3.60.0000.01414.82
7.3.50.0030.00614.80
7.3.40.0030.01314.75
7.3.30.0100.00314.84
7.3.20.0000.00916.58
7.3.10.0080.00816.71
7.3.00.0070.00716.86
7.2.330.0070.01116.82
7.2.320.0000.02016.42
7.2.310.0100.00716.46
7.2.300.0130.01016.73
7.2.290.0070.01016.51
7.2.260.0070.01315.11
7.2.250.0090.00914.95
7.2.240.0000.01514.98
7.2.230.0070.01115.01
7.2.220.0070.00715.18
7.2.210.0130.00314.68
7.2.200.0060.00915.13
7.2.190.0040.01114.86
7.2.180.0100.00715.17
7.2.170.0030.01415.02
7.2.160.0060.00615.03
7.2.150.0090.00616.81
7.2.140.0030.00916.98
7.2.130.0120.00617.18
7.2.120.0100.00717.10
7.2.110.0030.01017.00
7.2.100.0000.01617.06
7.2.90.0060.00616.76
7.2.80.0080.00817.07
7.2.70.0060.00916.95
7.2.60.0040.01117.09
7.2.50.0050.00516.86
7.2.40.0040.00717.05
7.2.30.0070.00716.88
7.2.20.0110.00416.82
7.2.10.0030.01016.79
7.2.00.0070.00718.28
7.1.330.0090.00615.81
7.1.320.0060.00915.82
7.1.310.0000.01515.78
7.1.300.0090.00316.01
7.1.290.0070.01015.68
7.1.280.0090.00315.80
7.1.270.0030.01015.75
7.1.260.0100.00315.76
7.1.250.0000.01216.03
7.1.240.0090.00615.89
7.1.230.0030.00715.71
7.1.220.0070.01015.81
7.1.210.0040.01115.96
7.1.200.0000.01515.57
7.1.190.0070.00716.00
7.1.180.0120.00315.86
7.1.170.0060.00915.59
7.1.160.0030.01415.86
7.1.150.0060.00915.91
7.1.140.0040.00815.95
7.1.130.0100.00315.75
7.1.120.0000.01315.89
7.1.110.0030.01015.64
7.1.100.0310.00815.77
7.1.90.0030.01215.98
7.1.80.0110.00415.96
7.1.70.0040.01016.56
7.1.60.0130.00517.70
7.1.50.0070.01425.28
7.1.40.0030.01015.79
7.1.30.0060.00615.70
7.1.20.0030.01515.77
7.1.10.0040.01115.92
7.1.00.0050.04019.12
7.0.330.0060.00315.36
7.0.320.0030.00715.42
7.0.310.0040.01115.32
7.0.300.0060.00615.37
7.0.290.0070.00315.38
7.0.280.0090.00415.38
7.0.270.0060.00915.62
7.0.260.0090.00015.41
7.0.250.0060.00615.41
7.0.240.0090.00615.29
7.0.230.0080.00415.64
7.0.220.0000.01215.50
7.0.210.0100.00315.46
7.0.200.0050.00815.83
7.0.190.0070.00715.40
7.0.180.0150.00415.37
7.0.170.0070.00715.38
7.0.160.0050.00915.36
7.0.150.0070.01115.34
7.0.140.0050.04118.73
7.0.130.0030.00915.61
7.0.120.0080.00815.34
7.0.110.0060.00615.33
7.0.100.0060.00915.39
7.0.90.0040.00815.58
7.0.80.0080.00315.52
7.0.70.0070.00715.36
7.0.60.0050.04217.74
7.0.50.0100.04316.70
7.0.40.0060.02616.89
7.0.30.0300.03517.02
7.0.20.0160.02916.77
7.0.10.0050.04816.76
7.0.00.0060.03116.81
5.6.400.0080.00814.46
5.6.390.0090.00314.69
5.6.380.0030.01014.43
5.6.370.0080.00413.95
5.6.360.0030.01014.64
5.6.350.0100.00314.28
5.6.340.0040.00714.39
5.6.330.0060.00314.44
5.6.320.0060.00314.30
5.6.310.0060.00314.25
5.6.300.0000.01614.42
5.6.290.0000.01814.25
5.6.280.0090.03517.63
5.6.270.0090.00614.45
5.6.260.0030.01314.38
5.6.250.0130.00314.23
5.6.240.0030.01314.51
5.6.230.0040.00814.68
5.6.220.0030.00914.34
5.6.210.0070.02217.39
5.6.200.0050.02716.19
5.6.190.0200.03517.62
5.6.180.0130.03017.48
5.6.170.0120.02417.43
5.6.160.0070.02517.48
5.6.150.0100.03416.21
5.6.140.0080.04116.26
5.6.130.0090.02916.40
5.6.120.0050.03417.67
5.6.110.0070.04617.75
5.6.100.0020.02717.66
5.6.90.0100.04317.66
5.6.80.0050.04417.31
5.6.70.2330.02517.31
5.6.60.0030.00714.37
5.6.50.0070.00714.57
5.6.40.0060.00614.43
5.6.30.0120.00014.36
5.6.20.0110.00314.21
5.6.10.0070.01114.32
5.6.00.0070.00714.33
5.5.380.0060.01014.19
5.5.370.0040.01414.39
5.5.360.0060.00614.70
5.5.350.0100.03717.34
5.5.340.0080.03016.18
5.5.330.0080.04517.39
5.5.320.0230.04317.24
5.5.310.0180.04317.39
5.5.300.0050.02916.10
5.5.290.0020.03016.12
5.5.280.0100.02817.63
5.5.270.0100.04017.62
5.5.260.0080.04217.53
5.5.250.0100.04017.48
5.5.240.0130.04617.10
5.5.230.0110.00314.16
5.5.220.0070.00414.11
5.5.210.0080.00814.37
5.5.200.0100.00314.33
5.5.190.0070.01314.25
5.5.180.0070.00714.31
5.5.170.0000.00914.31
5.5.160.0040.01114.18
5.5.150.0040.01114.04
5.5.140.0090.00614.06
5.5.130.0120.00314.41
5.5.120.0030.00914.28
5.5.110.0070.00714.47
5.5.100.0090.00614.50
5.5.90.0030.01214.43
5.5.80.0060.01214.32
5.5.70.0070.01014.26
5.5.60.0030.00614.33
5.5.50.0130.00014.18
5.5.40.0090.00914.18
5.5.30.0070.01014.16
5.5.20.0110.00414.05
5.5.10.0070.01014.32
5.5.00.0000.01514.22
5.4.450.0050.04015.38
5.4.440.0480.04315.34
5.4.430.0470.03515.33
5.4.420.0330.00515.29
5.4.410.0110.02914.97
5.4.400.0140.03014.72
5.4.390.0130.03214.80
5.4.380.0160.02814.90
5.4.370.0060.03114.71
5.4.360.0050.02914.77
5.4.350.0070.02611.47
5.4.340.0090.02211.43
5.4.330.0040.00411.20
5.4.320.0030.02311.97
5.4.310.0020.02911.80
5.4.300.0070.02011.89
5.4.290.0090.02011.90
5.4.280.0040.03411.70
5.4.270.0050.02011.83
5.4.260.0060.02211.65
5.4.250.0060.02611.85
5.4.240.0040.02311.56
5.4.230.0050.02511.66
5.4.220.0040.02411.62
5.4.210.0060.02311.78
5.4.200.0080.02211.65
5.4.190.0070.02311.51
5.4.180.0070.02311.77
5.4.170.0020.02611.68
5.4.160.0070.02111.76
5.4.150.0020.02611.56
5.4.140.0070.03711.48
5.4.130.0080.02511.41
5.4.120.0080.03011.59
5.4.110.0110.03311.55
5.4.100.0070.02311.51
5.4.90.0140.02211.39
5.4.80.0090.02711.56
5.4.70.0070.03011.58
5.4.60.0090.02811.54
5.4.50.0080.02711.57
5.4.40.0100.02311.57
5.4.30.0080.02811.54
5.4.20.0070.03111.57
5.4.10.0040.03011.42
5.4.00.0080.02111.11
5.3.290.0070.02511.55
5.3.280.0070.02511.50
5.3.270.0090.02711.51
5.3.260.0130.05611.51
5.3.250.0040.02911.51
5.3.240.0050.03311.51
5.3.230.0100.02711.50
5.3.220.0080.02511.49
5.3.210.0050.03611.49
5.3.200.0090.02611.49
5.3.190.0040.02511.49
5.3.180.0120.03111.49
5.3.170.0040.04311.51
5.3.160.0110.02511.50
5.3.150.0050.02911.49
5.3.140.0100.03211.51
5.3.130.0070.02211.48
5.3.120.0070.02911.48
5.3.110.0070.02411.48
5.3.100.0070.02011.24
5.3.90.0040.02811.19
5.3.80.0060.02211.19
5.3.70.0030.02411.18
5.3.60.0090.02411.18
5.3.50.0050.02311.15
5.3.40.0070.01911.15
5.3.30.0070.02611.12
5.3.20.0020.02911.00
5.3.10.0070.02710.98
5.3.00.0080.02110.98
5.2.170.0090.0419.15
5.2.160.0080.0369.16
5.2.150.0080.0359.15
5.2.140.0050.0349.14
5.2.130.0060.0319.10
5.2.120.0050.0359.11
5.2.110.0040.0419.11
5.2.100.0050.0439.11
5.2.90.0110.0399.11
5.2.80.0090.0439.11
5.2.70.0110.0419.11
5.2.60.0100.0429.05
5.2.50.0040.0459.03
5.2.40.0060.0429.00
5.2.30.0110.0408.98
5.2.20.0120.0358.97
5.2.10.0120.0348.90
5.2.00.0120.0408.77
5.1.60.0110.0338.05
5.1.50.0120.0518.04
5.1.40.0090.0498.03
5.1.30.0110.0458.38
5.1.20.0060.0308.40
5.1.10.0080.0298.12
5.1.00.0070.0278.12
5.0.50.0060.0216.60
5.0.40.0060.0216.46
5.0.30.0070.0386.27
5.0.20.0050.0236.24
5.0.10.0040.0276.22
5.0.00.0060.0326.21
4.4.90.0080.0204.78
4.4.80.0070.0224.75
4.4.70.0070.0224.75
4.4.60.0070.0354.76
4.4.50.0030.0304.77
4.4.40.0040.0364.71
4.4.30.0090.0314.76
4.4.20.0060.0214.84
4.4.10.0110.0484.84
4.4.00.0030.0364.76
4.3.110.0130.0204.67
4.3.100.0140.0294.66
4.3.90.0040.0234.64
4.3.80.0030.0484.58
4.3.70.0060.0254.63
4.3.60.0080.0214.63
4.3.50.0080.0244.62
4.3.40.0030.0434.54
4.3.30.0040.0293.27
4.3.20.0020.0243.25
4.3.10.0060.0213.22
4.3.00.0200.0176.91

preferences:
42.02 ms | 400 KiB | 5 Q