3v4l.org

run code in 300+ PHP versions simultaneously
<?php function numberOfPairs($a,$k){ $a=array_count_values($a); // enable use of the very fast isset() function and avoid iterating duplicates ksort($a); // order so that only the lower values need to be iterated foreach($a as $num=>$occur){ if(($double=$num*2)>=$k){ // we are at or past the middle if($double==$k && $occur>1) $result[]=[$num,$k-$num]; // addends are equal and 2 exist, store before break break; }elseif(isset($a[$k-$num])){ // matching addend found, store & continue $result[]=[$num,$k-$num]; } } var_export($result); } $a = [6,6,3,9,3,5,1]; $k = 12; numberOfPairs($a,$k);

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.5.10.0110.00616.65
8.5.00.0130.01319.86
8.4.150.0030.00014.05
8.4.140.0110.00917.76
8.4.130.0110.00917.43
8.4.120.0130.00720.47
8.4.110.0090.00822.58
8.4.100.0160.00517.81
8.4.90.0040.00517.84
8.4.80.0080.00717.65
8.4.70.0070.00117.80
8.4.60.0070.00418.50
8.4.50.0130.00819.54
8.4.40.0090.00619.68
8.4.30.0060.01317.59
8.4.20.0120.00017.70
8.4.10.0040.00419.41
8.3.280.0140.00618.47
8.3.270.0290.01216.26
8.3.260.0090.00816.65
8.3.250.0120.00718.83
8.3.240.0110.00816.63
8.3.230.0120.00716.60
8.3.220.0090.00717.28
8.3.210.0110.00816.50
8.3.200.0040.00516.60
8.3.190.0090.00619.19
8.3.180.0100.00516.68
8.3.170.0130.00616.49
8.3.160.0100.01016.49
8.3.150.0100.01017.49
8.3.140.0130.00619.00
8.3.130.0050.00318.27
8.3.120.0050.00318.93
8.3.110.0120.00020.94
8.3.100.0080.00824.06
8.3.90.0070.01126.77
8.3.80.0060.00317.97
8.3.70.0090.00616.38
8.3.60.0130.00716.37
8.3.50.0070.00518.16
8.3.40.0160.00018.76
8.3.30.0110.00718.85
8.3.20.0070.00021.91
8.3.10.0060.00323.56
8.3.00.0040.00421.77
8.2.290.0110.00820.46
8.2.280.0050.00420.04
8.2.270.0060.00316.86
8.2.260.0000.00816.69
8.2.250.0000.00816.61
8.2.240.0080.00018.84
8.2.230.0000.00822.58
8.2.220.0060.00337.54
8.2.210.0150.00026.77
8.2.200.0040.00416.75
8.2.190.0070.00716.63
8.2.180.0100.01016.75
8.2.170.0060.00922.96
8.2.160.0030.01022.32
8.2.150.0040.00424.18
8.2.140.0000.00724.66
8.2.130.0040.00419.32
8.2.120.0080.00026.35
8.2.110.0090.00020.95
8.2.100.0060.00617.91
8.2.90.0000.00819.17
8.2.80.0040.00418.16
8.2.70.0030.00717.63
8.2.60.0040.00418.05
8.2.50.0050.00518.22
8.2.40.0050.00220.42
8.2.30.0070.00019.20
8.2.20.0000.00718.14
8.2.10.0050.00318.19
8.2.00.0050.00218.20
8.1.330.0120.00618.45
8.1.320.0100.00916.23
8.1.310.0050.00318.45
8.1.300.0000.00818.14
8.1.290.0100.00030.84
8.1.280.0090.00625.92
8.1.270.0060.00322.11
8.1.260.0040.00426.35
8.1.250.0070.00028.09
8.1.240.0030.00619.19
8.1.230.0000.01120.44
8.1.220.0040.00417.77
8.1.210.0030.00618.77
8.1.200.0030.00617.35
8.1.190.0080.00017.23
8.1.180.0000.00718.10
8.1.170.0040.00418.59
8.1.160.0000.00718.90
8.1.150.0000.00818.82
8.1.140.0030.00319.07
8.1.130.0000.00717.68
8.1.120.0000.00817.50
8.1.110.0000.00717.48
8.1.100.0030.00517.50
8.1.90.0000.00817.48
8.1.80.0070.00017.53
8.1.70.0030.00317.38
8.1.60.0000.00817.60
8.1.50.0000.00717.44
8.1.40.0040.00417.46
8.1.30.0000.00817.59
8.1.20.0000.00817.60
8.1.10.0000.00817.59
8.1.00.0050.00317.54
8.0.300.0040.00418.77
8.0.290.0040.00416.75
8.0.280.0000.00818.54
8.0.270.0000.00716.83
8.0.260.0030.00317.14
8.0.250.0000.00716.89
8.0.240.0080.00016.97
8.0.230.0070.00016.90
8.0.220.0070.00016.95
8.0.210.0060.00316.91
8.0.200.0000.00616.86
8.0.190.0000.00716.94
8.0.180.0030.00316.82
8.0.170.0000.00816.95
8.0.160.0040.00416.80
8.0.150.0070.00016.92
8.0.140.0000.00716.76
8.0.130.0060.00013.29
8.0.120.0000.00716.98
8.0.110.0080.00016.84
8.0.100.0040.00416.97
8.0.90.0000.00716.82
8.0.80.0120.00316.82
8.0.70.0020.00516.75
8.0.60.0000.00716.85
8.0.50.0030.00516.86
8.0.30.0090.01017.15
8.0.20.0120.00617.33
8.0.10.0040.01117.09
8.0.00.0090.00616.86
7.4.330.0040.00015.55
7.4.320.0000.00616.61
7.4.300.0070.00016.46
7.4.290.0000.00716.59
7.4.280.0070.00016.61
7.4.270.0070.00016.62
7.4.260.0030.00616.51
7.4.250.0000.00716.46
7.4.240.0070.00016.61
7.4.230.0000.00716.64
7.4.220.0000.00716.27
7.4.210.0090.00916.59
7.4.200.0000.00716.46
7.4.160.0050.01216.48
7.4.150.0100.01217.02
7.4.140.0090.00917.60
7.4.130.0060.01016.49
7.4.120.0090.01016.45
7.4.110.0100.00616.57
7.4.100.0090.00716.58
7.4.90.0070.01016.40
7.4.80.0100.00917.87
7.4.70.0120.00616.53
7.4.60.0040.01216.52
7.4.50.0080.00816.47
7.4.40.0090.00716.47
7.4.30.0040.01416.51
7.4.20.0070.00716.48
7.4.10.0090.00916.35
7.4.00.0040.01015.35
7.3.330.0000.00613.16
7.3.320.0000.00613.24
7.3.310.0070.00016.16
7.3.300.0060.00016.24
7.3.290.0080.01116.32
7.3.280.0070.00916.31
7.3.270.0150.00716.86
7.3.260.0070.01016.45
7.3.250.0090.01016.35
7.3.240.0080.01016.43
7.3.230.0070.00816.32
7.3.220.0140.00016.25
7.3.210.0090.00616.40
7.3.200.0070.00916.44
7.3.190.0080.00916.42
7.3.180.0080.00916.32
7.3.170.0060.00816.42
7.3.160.0100.00916.46
7.3.150.0160.01616.23
7.3.140.0100.01116.30
7.3.130.0040.01116.36
7.3.120.0090.00715.35
7.3.110.0070.00715.22
7.3.100.0080.00615.27
7.3.90.0030.00915.42
7.3.80.0040.00915.42
7.3.70.0030.01015.29
7.3.60.0060.00815.36
7.3.50.0050.00915.50
7.3.40.0070.00615.30
7.3.30.0040.01015.34
7.3.20.0070.00716.62
7.3.10.0080.00716.39
7.3.00.0060.00616.68
7.2.340.0150.01216.45
7.2.330.0120.01216.51
7.2.320.0160.00816.60
7.2.310.0150.00716.52
7.2.300.0160.00816.47
7.2.290.0190.00716.63
7.2.280.0160.01216.43
7.2.270.0190.01216.45
7.2.260.0230.01016.42
7.2.250.0110.00815.46
7.2.240.0100.00915.54
7.2.230.0100.00815.61
7.2.220.0070.01115.49
7.2.210.0090.01215.56
7.2.200.0120.00615.35
7.2.190.0100.00615.65
7.2.180.0090.00815.67
7.2.170.0090.01115.56
7.2.160.0120.00915.87
7.2.150.0120.00916.84
7.2.140.0110.00716.75
7.2.130.0180.00816.85
7.2.120.0120.00717.80
7.2.110.0100.01017.80
7.2.100.0090.01017.71
7.2.90.0130.00817.81
7.2.80.0130.01317.73
7.2.70.0130.00717.62
7.2.60.0090.00717.38
7.2.50.0110.00817.72
7.2.40.0100.01317.73
7.2.30.0190.00816.82
7.2.20.0160.00616.82
7.2.10.0220.00717.23
7.2.00.0200.00817.23
7.1.330.0080.00915.75
7.1.320.0100.00615.68
7.1.310.0110.00515.64
7.1.300.0090.00615.70
7.1.290.0130.00615.75
7.1.280.0200.00615.69
7.1.270.0070.01015.74
7.1.260.0090.00915.75
7.1.250.0130.00516.42
7.1.240.0090.00716.63
7.1.230.0130.00616.67
7.1.220.0120.00516.44
7.1.210.0120.00916.74
7.1.200.0050.01316.40
7.1.190.0110.00516.62
7.1.180.0110.00716.52
7.1.170.0120.00516.48
7.1.160.0100.01116.63
7.1.150.0140.00415.69
7.1.140.0080.01115.57
7.1.130.0110.00915.65
7.1.120.0230.00615.98
7.1.110.0260.00515.75
7.1.100.0160.01115.79
7.1.90.0220.00915.70
7.1.80.0180.00715.72
7.1.70.0180.00815.54
7.1.60.0230.00721.46
7.1.50.0210.00621.43
7.1.40.0200.01021.31
7.1.30.0280.00921.47
7.1.20.0310.00721.31
7.1.10.0310.01015.30
7.1.00.0200.00815.48
7.0.330.0080.00816.29
7.0.320.0120.00416.19
7.0.310.0130.00616.04
7.0.300.0090.00616.26
7.0.290.0150.00516.15
7.0.280.0120.00515.31
7.0.270.0090.00715.32
7.0.260.0140.00915.30
7.0.250.0100.00915.29
7.0.240.0060.01315.51
7.0.230.0100.01015.41
7.0.220.0120.00415.50
7.0.210.0080.01215.46
7.0.200.0160.00315.39
7.0.190.0110.00715.38
7.0.180.0070.01115.32
7.0.170.0120.00615.48
7.0.160.0180.00415.45
7.0.150.0110.00815.39
7.0.140.0130.00815.36
7.0.130.0110.00815.42
7.0.120.0180.00215.44
7.0.110.0320.01215.34
7.0.100.0170.00815.31
7.0.90.0120.00815.27
7.0.80.0170.00415.31
7.0.70.0140.00815.32
7.0.60.0080.01415.44
7.0.50.0140.00815.33
7.0.40.0100.00914.37
7.0.30.0070.01114.47
7.0.20.0090.01114.36
7.0.10.0110.01014.42
7.0.00.0160.00014.40
5.6.400.0060.01015.26
5.6.390.0070.01015.20
5.6.380.0090.00715.16
5.6.370.0090.00915.29
5.6.360.0150.00515.15
5.6.350.0120.00615.31
5.6.340.0140.00415.15
5.6.330.0120.00715.10
5.6.320.0090.00915.19
5.6.310.0100.01315.29
5.6.300.0130.01014.96
5.6.290.0130.01015.29
5.6.280.0100.00715.31
5.6.270.0180.00315.35
5.6.260.0080.01315.19
5.6.250.0140.01115.23
5.6.240.0190.00315.28
5.6.230.0130.00715.10
5.6.220.0070.01215.16
5.6.210.0130.00815.21
5.6.200.0100.01115.51
5.6.190.0110.00515.29
5.6.180.0070.01315.26
5.6.170.0210.00515.29
5.6.160.0130.00615.31
5.6.150.0120.00715.16
5.6.140.0090.01415.15
5.6.130.0110.00915.34
5.6.120.0150.00815.45
5.6.110.0110.01115.33
5.6.100.0160.01115.15
5.6.90.0200.00315.20
5.6.80.0120.00815.18
5.6.70.0080.01215.24
5.6.60.0110.00915.30
5.6.50.0100.00715.10
5.6.40.0120.01215.10
5.6.30.0070.01615.31
5.6.20.0140.00415.12
5.6.10.0130.00415.08
5.6.00.0070.01315.20

preferences:
181.07 ms | 403 KiB | 5 Q