3v4l.org

run code in 300+ PHP versions simultaneously
<?php function concat_path_components($path_components) { $first_component = array_shift($path_components); if ($first_component == NULL) return ""; return array_reduce( $path_components, function ($path, $path_component) { return $path . DIRECTORY_SEPARATOR . $path_component; }, $first_component); } function path_components($path) { $components = array(); while ($path != "." && $path != "/") { array_unshift($components, basename($path)); $path = dirname($path); } if ($path == "/") array_unshift($components, "/"); return $components; } function path_relative_to($path, $rel) { $path_components = path_components($path); $copy = $path_components; $rel_components = path_components($rel); for($i = 0 ; $i < count($rel_components) ; ++$i) { if ($path_components[$i] == $rel[$i]) array_shift($copy); else break; } echo $i . " ". count($rel_components) . PHP_EOL; if ($i == count($rel_components)) return concat_path_components($copy); else return ""; } var_dump(path_relative_to("/a/b/c", "/a/bc"));

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.00916.63
8.3.50.0140.00522.12
8.3.40.0110.00418.46
8.3.30.0140.00019.21
8.3.20.0000.00820.33
8.3.10.0070.00023.71
8.3.00.0080.00019.38
8.2.180.0090.00616.37
8.2.170.0070.00722.96
8.2.160.0080.00820.52
8.2.150.0000.00824.18
8.2.140.0040.00424.66
8.2.130.0140.00026.16
8.2.120.0050.00322.21
8.2.110.0070.00422.27
8.2.100.0060.00617.91
8.2.90.0050.00319.35
8.2.80.0050.00318.05
8.2.70.0040.00417.50
8.2.60.0080.00018.16
8.2.50.0030.00618.07
8.2.40.0000.00718.34
8.2.30.0000.00718.07
8.2.20.0060.00317.64
8.2.10.0040.00418.09
8.2.00.0080.00017.76
8.1.280.0120.00625.92
8.1.270.0090.00923.97
8.1.260.0030.00526.35
8.1.250.0080.00028.09
8.1.240.0040.00423.96
8.1.230.0060.00618.92
8.1.220.0030.00517.74
8.1.210.0000.00818.77
8.1.200.0060.00317.23
8.1.190.0000.00717.40
8.1.180.0000.00818.10
8.1.170.0070.00418.48
8.1.160.0070.00022.04
8.1.150.0000.00718.54
8.1.140.0040.00417.39
8.1.130.0070.00017.91
8.1.120.0000.00717.39
8.1.110.0080.00017.40
8.1.100.0040.00717.54
8.1.90.0040.00417.38
8.1.80.0000.00717.49
8.1.70.0030.00317.45
8.1.60.0040.00417.61
8.1.50.0040.00417.46
8.1.40.0000.00717.50
8.1.30.0030.00517.63
8.1.20.0000.00717.68
8.1.10.0000.00717.53
8.1.00.0000.00817.45
8.0.300.0060.00318.77
8.0.290.0070.00017.18
8.0.280.0070.00018.56
8.0.270.0030.00317.19
8.0.260.0030.00316.88
8.0.250.0030.00317.02
8.0.240.0000.00716.93
8.0.230.0050.00217.00
8.0.220.0040.00416.96
8.0.210.0000.00716.93
8.0.200.0030.00316.96
8.0.190.0070.00016.84
8.0.180.0030.00516.98
8.0.170.0000.00816.91
8.0.160.0040.00416.78
8.0.150.0030.00316.90
8.0.140.0040.00416.79
8.0.130.0030.00313.43
8.0.120.0070.00015.07
8.0.110.0040.00315.14
8.0.100.0020.00615.05
8.0.90.0000.00815.06
8.0.80.0040.00715.13
8.0.70.0030.00515.13
8.0.60.0050.00315.12
8.0.50.0070.00115.12
8.0.30.0140.00515.88
8.0.20.0070.00916.05
8.0.10.0040.00415.13
8.0.00.0070.00715.64
7.4.330.0050.00015.09
7.4.320.0000.00716.53
7.4.300.0030.00316.51
7.4.290.0040.00416.55
7.4.280.0030.00316.65
7.4.270.0030.00316.60
7.4.260.0040.00716.59
7.4.250.0060.00114.96
7.4.240.0030.00515.42
7.4.230.0040.00314.91
7.4.220.0100.00714.93
7.4.210.0060.00815.73
7.4.200.0040.00414.95
7.4.190.0080.00014.86
7.4.180.0050.00213.36
7.4.160.0070.00714.89
7.4.150.0120.00215.33
7.4.140.0070.00916.34
7.4.130.0080.00915.40
7.4.120.0090.00715.50
7.4.110.0070.00814.91
7.4.100.0110.00514.88
7.4.90.0100.00514.89
7.4.80.0090.00716.35
7.4.70.0050.01014.86
7.4.60.0090.00314.87
7.4.50.0070.00114.76
7.4.40.0070.00618.00
7.4.30.0070.00814.88
7.4.20.0080.00013.30
7.4.10.0080.00013.37
7.4.00.0070.00514.13
7.3.330.0020.00213.35
7.3.320.0060.00013.23
7.3.310.0010.00614.90
7.3.300.0040.00314.81
7.3.290.0090.00514.81
7.3.280.0080.00815.58
7.3.270.0100.00315.32
7.3.260.0070.00514.80
7.3.250.0080.00615.37
7.3.240.0080.00614.79
7.3.230.0090.00314.77
7.3.220.0000.00813.27
7.3.210.0030.01014.86
7.3.200.0090.00616.25
7.3.190.0070.00714.92
7.3.180.0100.00414.84
7.3.170.0100.00114.83
7.3.160.0030.01014.85
7.3.150.0060.00013.32
7.3.140.0000.00613.15
7.3.130.0000.00513.13
7.3.120.0040.00713.85
7.3.110.0000.00613.18
7.3.100.0000.00613.25
7.3.90.0060.00013.38
7.3.80.0000.00613.25
7.3.70.0030.00313.43
7.3.60.0000.00613.33
7.3.50.0030.00313.53
7.3.40.0030.00313.50
7.3.30.0000.00513.47
7.3.20.0070.00015.13
7.3.10.0150.00615.75
7.3.00.0040.01015.78
7.2.340.0120.00013.45
7.2.330.0070.00815.09
7.2.320.0080.00715.12
7.2.310.0110.00415.09
7.2.300.0090.00815.13
7.2.290.0080.00914.97
7.2.280.0130.00013.41
7.2.270.0100.00313.50
7.2.260.0130.00013.44
7.2.250.0090.00313.33
7.2.240.0000.01213.29
7.2.230.0080.00413.32
7.2.220.0060.00613.50
7.2.210.0100.00313.25
7.2.200.0110.00213.60
7.2.190.0060.00613.45
7.2.180.0090.00413.43
7.2.170.0100.00213.44
7.2.160.0040.00813.52
7.2.150.0140.00015.36
7.2.140.0130.00015.30
7.2.130.0160.00916.20
7.2.120.0130.00616.19
7.2.110.0080.00716.11
7.2.100.0090.00516.24
7.2.90.0070.00616.26
7.2.80.0060.00516.10
7.2.70.0110.00316.11
7.2.60.0130.00215.97
7.2.50.0130.00016.17
7.2.40.0060.00616.10
7.2.30.0050.00816.13
7.2.20.0040.01016.16
7.2.10.0080.00316.11
7.2.00.0060.00717.19
7.1.330.0000.01214.47
7.1.320.0060.00614.39
7.1.310.0080.00414.19
7.1.300.0120.00014.38
7.1.290.0000.01214.25
7.1.280.0080.00414.29
7.1.270.0060.00614.38
7.1.260.0060.00614.29
7.1.250.0070.00915.04
7.1.240.0000.01214.32
7.1.230.0090.00314.25
7.1.220.0110.00014.23
7.1.210.0000.01214.21
7.1.200.0120.00014.38
7.1.190.0090.00214.36
7.1.180.0060.00614.35
7.1.170.0040.00814.33
7.1.160.0000.01214.19
7.1.150.0090.00314.35
7.1.140.0120.00014.30
7.1.130.0120.00014.32
7.1.120.0070.00514.10
7.1.110.0090.00214.36
7.1.100.0070.00716.27
7.1.90.0060.00614.34
7.1.80.0120.00014.40
7.1.70.0040.00615.63
7.1.60.0100.00516.85
7.1.50.0110.00815.59
7.1.40.0110.00214.24
7.1.30.0120.00014.40
7.1.20.0090.00314.20
7.1.10.0100.00214.28
7.1.00.0030.04118.22
7.0.330.0060.00614.13
7.0.320.0080.00414.11
7.0.310.0120.00014.05
7.0.300.0120.00014.13
7.0.290.0060.00614.29
7.0.280.0120.00014.02
7.0.270.0060.00614.05
7.0.260.0110.00014.06
7.0.250.0130.00014.35
7.0.240.0090.00314.23
7.0.230.0110.00014.36
7.0.220.0080.00414.23
7.0.210.0060.00614.14
7.0.200.0060.00615.47
7.0.190.0080.00414.32
7.0.180.0070.00514.35
7.0.170.0120.00014.36
7.0.160.0090.00314.21
7.0.150.0120.00014.21
7.0.140.0070.03518.12
7.0.130.0080.00414.32
7.0.120.0120.00014.18
7.0.110.0000.01114.22
7.0.100.0060.00614.24
7.0.90.0120.00014.13
7.0.80.0060.00613.97
7.0.70.0050.04417.99
7.0.60.0080.03317.88
7.0.50.0030.04818.16
7.0.40.0070.04217.14
7.0.30.0050.04717.14
7.0.20.0050.04217.19
7.0.10.0120.03317.09
7.0.00.0070.04317.19
5.6.400.0000.01112.61
5.6.390.0060.00612.55
5.6.380.0000.01212.86
5.6.370.0030.00812.76
5.6.360.0070.00512.57
5.6.350.0110.00012.61
5.6.340.0060.00612.85
5.6.330.0000.01212.76
5.6.320.0110.00012.86
5.6.310.0080.00412.79
5.6.300.0140.00012.66
5.6.290.0080.00312.95
5.6.280.0080.03616.99
5.6.270.0110.00012.90
5.6.260.0110.00012.79
5.6.250.0080.00312.78
5.6.240.0080.00312.71
5.6.230.0060.00613.07
5.6.220.0080.04316.68
5.6.210.0050.04816.89
5.6.200.0070.02717.07
5.6.190.0110.04216.93
5.6.180.0110.04216.98
5.6.170.0060.04617.05
5.6.160.0100.04117.02
5.6.150.0090.03817.05
5.6.140.0040.03516.96
5.6.130.0090.03017.04
5.6.120.0070.04016.91
5.6.110.0060.04316.87
5.6.100.0060.03716.99
5.6.90.0040.03516.94
5.6.80.0090.03716.52
5.6.70.0060.04116.70
5.6.60.0070.04016.84
5.6.50.0060.04016.60
5.6.40.0070.04416.63
5.6.30.0070.04316.64
5.6.20.0020.03416.51
5.6.10.0070.04216.63
5.6.00.0050.03016.54
5.5.380.0110.00013.04
5.5.370.0110.00013.13
5.5.360.0070.04416.54
5.5.350.0060.04216.67
5.5.340.0060.03916.82
5.5.330.0090.03816.80
5.5.320.0100.04016.80
5.5.310.0090.03216.91
5.5.300.0060.03016.78
5.5.290.0050.02416.91
5.5.280.0020.05116.92
5.5.270.0060.04516.78
5.5.260.0100.04016.65
5.5.250.0090.04216.70
5.5.240.0090.03716.49
5.5.230.0070.04316.38
5.5.220.0060.02816.50
5.5.210.0040.04316.59
5.5.200.0070.03816.49
5.5.190.0090.04016.49
5.5.180.0040.04416.56
5.5.170.0070.00412.67
5.5.160.0040.04316.44
5.5.150.0040.04416.43
5.5.140.0070.04016.45
5.5.130.0070.03016.26
5.5.120.0060.04316.36
5.5.110.0040.04016.33
5.5.100.0070.03816.39
5.5.90.0070.04016.47
5.5.80.0060.04316.31
5.5.70.0070.04116.39
5.5.60.0070.03816.47
5.5.50.0050.02816.38
5.5.40.0070.03916.51
5.5.30.0040.03316.50
5.5.20.0070.04016.32
5.5.10.0050.04316.41
5.5.00.0060.04316.41
5.4.450.0090.03016.26
5.4.440.0040.04716.19
5.4.430.0070.04016.05
5.4.420.0040.04416.11
5.4.410.0040.04015.92
5.4.400.0100.04015.72
5.4.390.0050.04115.76
5.4.380.0040.04115.82
5.4.370.0140.03515.83
5.4.360.0070.04015.93
5.4.350.0030.04015.94
5.4.340.0040.04315.88
5.4.330.0080.00312.76
5.4.320.0050.03815.93
5.4.310.0060.03515.97
5.4.300.0070.03815.95
5.4.290.0030.04316.00
5.4.280.0060.03215.91
5.4.270.0040.03615.84
5.4.260.0060.04315.91
5.4.250.0090.02815.84
5.4.240.0050.04216.03
5.4.230.0090.03715.70
5.4.220.0070.03515.87
5.4.210.0070.03915.87
5.4.200.0040.04015.88
5.4.190.0050.02715.79
5.4.180.0070.04415.73
5.4.170.0060.04115.91
5.4.160.0070.02815.84
5.4.150.0050.04315.88
5.4.140.0020.04514.51
5.4.130.0030.03914.61
5.4.120.0070.03514.56
5.4.110.0090.03014.69
5.4.100.0050.04014.50
5.4.90.0090.03714.68
5.4.80.0040.04014.61
5.4.70.0050.03814.68
5.4.60.0090.03714.67
5.4.50.0040.03514.62
5.4.40.0050.03914.64
5.4.30.0040.04114.55
5.4.20.0060.03114.60
5.4.10.0040.02614.65
5.4.00.0040.02314.24
5.3.290.0030.04013.90
5.3.280.0030.04213.79
5.3.270.0050.04213.82
5.3.260.0040.03813.93
5.3.250.0030.04213.82
5.3.240.0030.03213.71
5.3.230.0090.03513.79
5.3.220.0010.03713.78
5.3.210.0050.03713.75
5.3.200.0040.04113.70
5.3.190.0060.03813.86
5.3.180.0050.03313.84
5.3.170.0040.04213.77
5.3.160.0080.03813.83
5.3.150.0050.03913.80
5.3.140.0020.03213.81
5.3.130.0040.03913.83
5.3.120.0050.04113.76
5.3.110.0030.04213.82
5.3.100.0090.01513.47
5.3.90.0030.04013.64
5.3.80.0070.02813.54
5.3.70.0080.03313.45
5.3.60.0070.03713.51
5.3.50.0050.03813.39
5.3.40.0070.02913.62
5.3.30.0050.02513.54
5.3.20.0050.03513.25
5.3.10.0050.04013.34
5.3.00.0050.03813.23
5.2.170.0060.03212.05
5.2.160.0040.03211.98
5.2.150.0020.02212.08
5.2.140.0040.01511.93
5.2.130.0050.03112.06
5.2.120.0030.03512.01
5.2.110.0040.03212.07
5.2.100.0080.03012.06
5.2.90.0060.02712.06
5.2.80.0040.03211.93
5.2.70.0050.03312.01
5.2.60.0050.03111.98
5.2.50.0040.02512.08
5.2.40.0070.03011.96
5.2.30.0050.03312.05
5.2.20.0060.03011.93
5.2.10.0060.03011.95
5.2.00.0040.03411.88
5.1.60.0050.02711.57
5.1.50.0040.02611.49
5.1.40.0040.02811.52
5.1.30.0040.01911.58
5.1.20.0040.01711.50
5.1.10.0040.02511.46
5.1.00.0020.03011.43
5.0.50.0050.02311.39
5.0.40.0040.01911.39
5.0.30.0100.02311.39
5.0.20.0010.01611.39
5.0.10.0050.02211.39
5.0.00.0040.02811.39
4.4.90.0000.02011.39
4.4.80.0020.01811.39
4.4.70.0000.01511.39
4.4.60.0030.01711.39
4.4.50.0000.02011.39
4.4.40.0020.02211.39
4.4.30.0030.01811.39
4.4.20.0040.01811.39
4.4.10.0070.01511.39
4.4.00.0020.02811.39
4.3.110.0030.01711.39
4.3.100.0020.01211.39
4.3.90.0050.01211.39
4.3.80.0020.02811.39
4.3.70.0030.01711.39
4.3.60.0000.01911.39
4.3.50.0000.01711.39
4.3.40.0030.02511.39
4.3.30.0000.02111.39
4.3.20.0050.01311.39
4.3.10.0010.02011.39
4.3.00.0030.01311.39

preferences:
44.17 ms | 401 KiB | 5 Q