3v4l.org

run code in 300+ PHP versions simultaneously
<?php function ipv6_addr_in_subnet($addr, $subnet, $mask = null) { $addrBin = @inet_pton($addr); if (!$addrBin) { throw new \InvalidArgumentException('Invalid IPv6 address: ' . $addr); } $cidr = 0; if (isset($mask)) { if (is_int($mask)) { $cidr = (int)$mask; if ($cidr < 0 || $cidr > 128) { throw new \InvalidArgumentException('Invalid IPv6 CIDR mask: ' . $mask); } } else { $maskBin = @inet_pton($mask); if (!$maskBin) { throw new \InvalidArgumentException('Invalid IPv6 mask: ' . $mask); } } $subnetAddr = $subnet; } else { $parts = explode('/', $subnet); $numParts = count($parts); if ($numParts === 1) { $maskBin = "\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"; } else if ($numParts === 2) { $cidr = (int)$parts[1]; } else { throw new \InvalidArgumentException('Invalid IPv6 subnet'); } $subnetAddr = $parts[0]; } if (!isset($maskBin)) { $blocks = (int)($cidr / 16); $maskBin = pack( 'n*', ...array_fill(0, $blocks, 0xffff), ...array_pad([((2 ** (16 - ($cidr % 16))) - 1) ^ 0xffff], 8 - $blocks, 0) ); } $subnetAddrBin = @inet_pton($subnetAddr); if (!$subnetAddrBin) { throw new \InvalidArgumentException('Invalid IPv6 address: ' . $subnetAddr); } return ($addrBin & $maskBin) === ($subnetAddrBin & $maskBin); } var_dump(ipv6_addr_in_subnet('::1', '::/0')); var_dump(ipv6_addr_in_subnet('::1', '::/128'));

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.0030.01518.30
8.3.50.0140.00718.05
8.3.40.0070.00718.85
8.3.30.0200.00322.96
8.3.20.0100.00323.66
8.2.180.0070.00725.92
8.2.170.0110.00718.96
8.2.160.0110.00422.96
8.2.150.0100.00722.96
8.2.140.0100.00322.96
8.1.280.0040.01125.92
8.1.270.0110.00424.01
7.4.10.0270.00616.52
7.4.00.0090.00815.56
7.3.130.0200.00316.22
7.3.120.0150.00515.71
7.3.110.0080.01315.81
7.3.100.0110.01115.85
7.3.90.0190.00415.60
7.3.80.0210.00815.57
7.3.70.0140.00915.63
7.3.60.0100.01015.66
7.3.50.0100.00815.52
7.3.40.0160.00315.66
7.3.30.0130.00615.53
7.3.20.0320.00716.59
7.3.10.0210.00816.70
7.3.00.0120.00616.69
7.2.260.0150.01316.83
7.2.250.0110.01415.86
7.2.240.0060.01416.10
7.2.230.0140.01115.68
7.2.220.0120.01115.82
7.2.210.0090.01116.07
7.2.200.0130.00815.87
7.2.190.0130.00515.92
7.2.180.0090.00915.87
7.2.170.0130.01015.87
7.2.160.0100.01115.83
7.2.150.0320.00216.63
7.2.140.0280.00816.93
7.2.130.0140.01017.03
7.2.120.0160.00917.83
7.2.110.0100.00816.90
7.2.100.0090.01117.82
7.2.90.0200.01014.38
7.2.80.0290.00314.27
7.2.70.0310.01214.43
7.2.60.0150.00315.83
7.2.50.0200.00514.36
7.2.40.0170.00414.36
7.2.30.0240.01216.94
7.2.20.0200.00617.58
7.2.10.0150.01016.68
7.2.00.0180.01018.34
7.1.330.0340.01515.96
7.1.320.0390.01015.82
7.1.310.0430.00815.89
7.1.300.0190.00615.79
7.1.290.0090.01016.58
7.1.280.0290.00515.78
7.1.270.0140.00816.54
7.1.260.0150.00716.80
7.1.250.0100.00716.74
7.1.240.0340.01415.62
7.1.230.0110.00915.72
7.1.220.0210.00615.77
7.1.210.0160.00416.53
7.1.200.0090.00814.42
7.1.190.0250.00113.63
7.1.180.0220.00913.82
7.1.170.0130.00613.83
7.1.160.0120.01216.61
7.1.150.0300.00715.73
7.1.140.0420.00713.80
7.1.130.0480.00513.66
7.1.120.0290.01315.83
7.1.110.0290.00315.79
7.1.100.0240.00616.65
7.1.90.0180.00915.72
7.1.80.0150.00715.87
7.1.70.0100.01016.24
7.1.60.0280.01116.96
7.1.50.0120.00815.32
7.1.40.0280.00715.77
7.1.30.0150.00613.79
7.1.20.0260.01415.82
7.1.10.0080.00613.82
7.1.00.0120.02816.64
7.0.330.0230.00315.34
7.0.320.0100.00915.30
7.0.310.0100.00913.61
7.0.300.0190.00915.47
7.0.290.0270.01215.22
7.0.280.0250.00415.31
7.0.270.0550.00315.30
7.0.260.0080.01115.43
7.0.250.0100.01116.27
7.0.240.0110.00716.17
7.0.230.0340.00615.41
7.0.220.0130.00916.37
7.0.210.0130.01016.17
7.0.200.0100.01016.42
7.0.190.0240.00313.38
7.0.180.0080.01213.58
7.0.170.0290.00315.36
7.0.160.0070.01113.50
7.0.150.0170.00314.18
7.0.140.0270.02217.62
7.0.130.0230.00613.57
7.0.120.0050.00913.59
7.0.110.0490.00615.44
7.0.100.0090.00913.54
7.0.90.0270.00915.37
7.0.80.0160.00916.33
7.0.70.0090.01416.29
7.0.60.0290.03717.01
7.0.50.0230.02314.99
7.0.40.0090.01815.14
7.0.30.0140.01816.33
7.0.20.0140.03316.19
7.0.10.0070.02215.04
7.0.00.0120.01915.09
5.6.400.0060.01415.38
5.6.390.0160.00415.17
5.6.380.0100.00815.40
5.6.370.0090.01115.25
5.6.360.0140.00515.09
5.6.350.0100.00815.03
5.6.340.0100.00613.14
5.6.330.0060.00612.97
5.6.320.0100.00712.89
5.6.310.0060.01012.88
5.6.300.0110.00213.13
5.6.290.0130.00113.11
5.6.280.0140.02617.34
5.6.270.0130.00313.11
5.6.260.0080.01015.09
5.6.250.0120.00313.22
5.6.240.0150.00815.35
5.6.230.0120.01015.37
5.6.220.0060.01415.18
5.6.210.0100.01817.10
5.6.200.0090.02016.28
5.6.190.0120.03317.00
5.6.180.1360.02617.10
5.6.170.0150.03017.05
5.6.160.0050.02117.00
5.6.150.0070.03516.18
5.6.140.0100.02716.09
5.6.130.0090.03114.78
5.6.120.0100.02717.40
5.6.110.0100.02217.19
5.6.100.0100.02417.20
5.6.90.0120.02617.14
5.6.80.0110.02717.02
5.6.70.1570.02016.93
5.6.60.0130.00612.91
5.6.50.0080.01014.91
5.6.40.0160.00415.18
5.6.30.0100.01015.16
5.6.20.0130.00715.11
5.6.10.0140.00514.98
5.6.00.0100.00715.01
5.5.380.0080.01314.85
5.5.370.0110.01114.62
5.5.360.0090.00712.76
5.5.350.0170.03016.70
5.5.340.0060.02015.77
5.5.330.0120.02816.60
5.5.320.0180.02716.57
5.5.310.0180.02516.60
5.5.300.0100.01915.88
5.5.290.0140.02615.93
5.5.280.0080.02516.97
5.5.270.0090.02416.75
5.5.260.0070.02116.73
5.5.250.0140.02916.77
5.5.240.0160.02916.57
5.5.230.0080.01014.64
5.5.220.0160.00414.67
5.5.210.0080.00914.67
5.5.200.0090.01014.61
5.5.190.0100.01314.64
5.5.180.0100.00914.65
5.5.170.0100.00814.68
5.5.160.0090.00914.51
5.5.150.0110.01114.57
5.5.140.0060.01114.95
5.5.130.0070.01414.68
5.5.120.0120.00514.55
5.5.110.0050.01114.92
5.5.100.0080.01114.85
5.5.90.0100.01114.74
5.5.80.0130.00514.71
5.5.70.0120.00814.59
5.5.60.0110.00414.71
5.5.50.0110.00714.53
5.5.40.0090.01014.65
5.5.30.0020.01414.70
5.5.20.0140.00514.79
5.5.10.0030.01514.71
5.5.00.0090.01014.73
5.4.450.1390.01614.26
5.4.440.0010.02214.27
5.4.430.1400.01614.32
5.4.420.1050.01814.17
5.4.410.1320.01314.20
5.4.400.1120.01614.09
5.4.390.0330.01814.01
5.4.380.1130.01714.09
5.4.370.1320.01713.96
5.4.360.1310.01414.07
5.4.350.1270.01714.09
5.4.340.1320.01514.09
5.4.330.0050.00511.59
5.4.320.1290.01814.06
5.4.310.1310.01614.05
5.4.300.1280.01614.13
5.4.290.1230.01614.11
5.4.280.1320.01914.08
5.4.270.1340.01514.15
5.4.260.1350.01614.00
5.4.250.1340.01514.05
5.4.240.1290.01714.21
5.4.230.1220.01813.99
5.4.220.1470.01513.94
5.4.210.1430.01714.13
5.4.200.1420.01914.08
5.4.190.1240.01714.03
5.4.180.1290.01414.08
5.4.170.1280.01213.96
5.4.160.1370.01614.13
5.4.150.1170.01514.03
5.4.140.1320.02013.41
5.4.130.1350.01713.14
5.4.120.1370.02113.24
5.4.110.1430.01613.19
5.4.100.1330.01713.28
5.4.90.1250.02013.20
5.4.80.1290.01313.21
5.4.70.1080.01513.15
5.4.60.1170.01713.29
5.4.50.1250.01813.23
5.4.40.1230.01713.15
5.4.30.1210.01813.25
5.4.20.1240.01713.25
5.4.10.1320.01613.16
5.4.00.1140.01612.96
5.3.290.3500.04014.70
5.3.280.3600.04014.69
5.3.270.3870.04314.70
5.3.260.4000.03314.62
5.3.250.3670.03014.64
5.3.240.3670.03314.53
5.3.230.3970.03714.69
5.3.220.3630.03014.59
5.3.210.3730.04014.80
5.3.200.3670.04014.66
5.3.190.3500.03314.63
5.3.180.3600.03714.59
5.3.170.3700.03314.48
5.3.160.3670.03714.73
5.3.150.3570.04314.80
5.3.140.3600.03314.58
5.3.130.3900.03714.47
5.3.120.3700.03314.47
5.3.110.3670.03314.78
5.3.100.3600.03314.05
5.3.90.3830.04314.05
5.3.80.3630.03714.03
5.3.70.4400.03013.93
5.3.60.0000.04013.92
5.3.50.0030.03713.98
5.3.40.3630.03713.88
5.3.30.3900.03313.85
5.3.20.3670.03713.63
5.3.10.3600.03713.82
5.3.00.3630.04013.56
5.2.170.0100.04711.32
5.2.160.0700.03011.09
5.2.150.3130.02311.24
5.2.140.3230.02311.07
5.2.130.3300.02711.03
5.2.120.2730.03311.02
5.2.110.3000.03011.03
5.2.100.3100.02711.21
5.2.90.3030.02711.04
5.2.80.3270.03311.03
5.2.70.3030.03011.08
5.2.60.3200.03311.07
5.2.50.2970.03010.95
5.2.40.2630.02710.93
5.2.30.2470.03010.89
5.2.20.2430.02310.93
5.2.10.2000.03010.99
5.2.00.0000.03010.89
5.1.60.0000.0279.90
5.1.50.0030.02310.25
5.1.40.0030.02310.00
5.1.30.1600.03010.30
5.1.20.2300.03010.37
5.1.10.1530.02310.16
5.1.00.1330.02310.31
5.0.50.1200.0238.50
5.0.40.1300.0178.37
5.0.30.1230.0308.22
5.0.20.0900.0208.24
5.0.10.1230.0178.11
5.0.00.0670.0278.31
4.4.90.1530.0137.81
4.4.80.1200.0177.81
4.4.70.1230.0137.81
4.4.60.1370.0137.81
4.4.50.1230.0177.81
4.4.40.0030.0237.81
4.4.30.0000.0177.81
4.4.20.0200.0177.81
4.4.10.1070.0177.81
4.4.00.1270.0237.81
4.3.110.1270.0137.81
4.3.100.1230.0137.81
4.3.90.0930.0137.81
4.3.80.1000.0237.81
4.3.70.1230.0137.81
4.3.60.1030.0137.81
4.3.50.1230.0137.81
4.3.40.1270.0237.81
4.3.30.0630.0137.81
4.3.20.0630.0137.81
4.3.10.0630.0137.81
4.3.00.0670.0177.81

preferences:
46.25 ms | 401 KiB | 5 Q