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) -1) 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.0120.00918.18
8.3.50.0130.00522.11
8.3.40.0040.01118.84
8.3.30.0130.00318.70
8.3.20.0000.00818.55
8.3.10.0030.00521.09
8.3.00.0040.00423.66
8.2.180.0110.00716.88
8.2.170.0000.01422.96
8.2.160.0070.00720.52
8.2.150.0050.00324.18
8.2.140.0040.00424.66
8.2.130.0040.00426.16
8.2.120.0060.00321.03
8.2.110.0060.00320.58
8.2.100.0000.01117.72
8.2.90.0050.00319.34
8.2.80.0080.00019.21
8.2.70.0090.00317.50
8.2.60.0030.00618.04
8.2.50.0090.00018.07
8.2.40.0080.00018.34
8.2.30.0000.00719.34
8.2.20.0030.00517.73
8.2.10.0060.00317.65
8.2.00.0070.00417.64
8.1.280.0060.00925.92
8.1.270.0000.00823.99
8.1.260.0060.00326.35
8.1.250.0040.00428.09
8.1.240.0030.01322.45
8.1.230.0040.00720.94
8.1.220.0050.00318.77
8.1.210.0000.00818.96
8.1.200.0030.00617.35
8.1.190.0040.00417.52
8.1.180.0050.00318.10
8.1.170.0050.00318.54
8.1.160.0030.00418.82
8.1.150.0000.00718.66
8.1.140.0040.00417.48
8.1.130.0030.00317.75
8.1.120.0050.00317.48
8.1.110.0040.00417.41
8.1.100.0050.00317.47
8.1.90.0000.00717.40
8.1.80.0000.00717.39
8.1.70.0000.00717.49
8.1.60.0000.00817.61
8.1.50.0000.00817.44
8.1.40.0030.00617.53
8.1.30.0050.00217.66
8.1.20.0030.00517.55
8.1.10.0000.00717.65
8.1.00.0080.00017.57
8.0.300.0040.00419.88
8.0.290.0000.00717.18
8.0.280.0040.00418.38
8.0.270.0000.00717.20
8.0.260.0000.00616.77
8.0.250.0050.00216.97
8.0.240.0030.00616.82
8.0.230.0030.00316.94
8.0.220.0030.00316.79
8.0.210.0000.00816.94
8.0.200.0080.00016.89
8.0.190.0040.00416.91
8.0.180.0030.00517.00
8.0.170.0070.00016.95
8.0.160.0000.00716.89
8.0.150.0000.00716.84
8.0.140.0050.00316.80
8.0.130.0000.00613.35
8.0.120.0050.00315.13
8.0.110.0040.00415.12
8.0.100.0040.00415.08
8.0.90.0040.00315.05
8.0.80.0060.00615.15
8.0.70.0020.00515.08
8.0.60.0000.00715.08
8.0.50.0030.00314.98
8.0.30.0080.00615.79
8.0.20.0090.00616.04
8.0.10.0030.00415.18
8.0.00.0050.00815.66
7.4.330.0050.00016.89
7.4.320.0030.00316.61
7.4.300.0000.00616.52
7.4.290.0070.00016.48
7.4.280.0040.00416.54
7.4.270.0030.00316.50
7.4.260.0000.00513.25
7.4.250.0050.00214.96
7.4.240.0050.00214.95
7.4.230.0050.00214.97
7.4.220.0070.00414.93
7.4.210.0060.00815.98
7.4.200.0050.00215.04
7.4.190.0050.00214.93
7.4.180.0030.00313.32
7.4.160.0080.00314.93
7.4.150.0100.00215.36
7.4.140.0080.00716.31
7.4.130.0130.00315.46
7.4.120.0040.01115.49
7.4.110.0190.00814.80
7.4.100.0070.00414.95
7.4.90.0050.00714.89
7.4.80.0060.00616.33
7.4.70.0060.00614.93
7.4.60.0060.00614.94
7.4.50.0040.00314.90
7.4.40.0060.00517.96
7.4.30.0060.00814.83
7.4.20.0030.00313.14
7.4.10.0030.00313.36
7.4.00.0030.00714.34
7.3.330.0000.00513.34
7.3.320.0060.00013.19
7.3.310.0030.00314.86
7.3.300.0060.00214.85
7.3.290.0070.00514.87
7.3.280.0070.00715.62
7.3.270.0050.01115.38
7.3.260.0070.00816.99
7.3.250.0080.00615.36
7.3.240.0100.00314.81
7.3.230.0090.00314.91
7.3.220.0030.00513.32
7.3.210.0110.00314.89
7.3.200.0100.00716.36
7.3.190.0100.00814.85
7.3.180.0140.00415.01
7.3.170.0090.00714.86
7.3.160.0060.00714.91
7.3.150.0000.00713.13
7.3.140.0000.00613.30
7.3.130.0030.00313.16
7.3.120.0030.00715.22
7.3.110.0040.00615.18
7.3.100.0050.00715.17
7.3.90.0110.00015.28
7.3.80.0020.00715.23
7.3.70.0060.00115.29
7.3.60.0010.00715.34
7.3.50.0060.00215.31
7.3.40.0050.00215.32
7.3.30.0030.00515.31
7.3.20.0030.00716.16
7.3.10.0020.00916.10
7.3.00.0020.00816.09
7.2.340.0060.00613.29
7.2.330.0090.00615.06
7.2.320.0120.00414.90
7.2.310.0030.01215.02
7.2.300.0120.00414.88
7.2.290.0070.00815.05
7.2.280.0080.00413.33
7.2.270.0080.00413.30
7.2.260.0110.00313.34
7.2.250.0120.00013.32
7.2.240.0070.00615.22
7.2.230.0050.00915.20
7.2.220.0080.00715.20
7.2.210.0080.00615.29
7.2.200.0090.00715.40
7.2.190.0070.00715.38
7.2.180.0090.00515.38
7.2.170.0080.00815.36
7.2.160.0030.01115.41
7.2.150.0100.00616.16
7.2.140.0110.00216.30
7.2.130.0110.00316.36
7.2.120.0090.00316.22
7.2.110.0100.00516.33
7.2.100.0090.00516.23
7.2.90.0060.00816.32
7.2.80.0000.01216.30
7.2.70.0080.00616.27
7.2.60.0060.01016.46
7.2.50.0040.00916.28
7.2.40.0070.00716.24
7.2.30.0070.00816.29
7.2.20.0060.00916.35
7.2.10.0090.00716.33
7.2.00.0050.00817.36
7.1.330.0090.00515.70
7.1.320.0110.00315.77
7.1.310.0060.00815.81
7.1.300.0050.00815.71
7.1.290.0110.00315.77
7.1.280.0060.00815.74
7.1.270.0050.00815.70
7.1.260.0050.00915.76
7.1.250.0060.00815.78
7.1.240.0090.00214.32
7.1.230.0040.00814.28
7.1.220.0040.00814.29
7.1.210.0000.01214.34
7.1.200.0040.00814.97
7.1.190.0060.00614.33
7.1.180.0120.00014.41
7.1.170.0060.00614.32
7.1.160.0060.00614.27
7.1.150.0040.00914.23
7.1.140.0120.00014.32
7.1.130.0110.00314.35
7.1.120.0060.00614.35
7.1.110.0090.00214.36
7.1.100.0070.00616.23
7.1.90.0070.00514.16
7.1.80.0060.00614.24
7.1.70.0060.00515.77
7.1.60.0060.00615.79
7.1.50.0090.00315.61
7.1.40.0100.00314.27
7.1.30.0120.00014.42
7.1.20.0070.00514.18
7.1.10.0060.00614.17
7.1.00.0080.01718.35
7.0.330.0060.00614.10
7.0.320.0110.00014.32
7.0.310.0080.00414.19
7.0.300.0080.00414.20
7.0.290.0120.00014.25
7.0.280.0090.00214.10
7.0.270.0130.00014.20
7.0.260.0110.00014.13
7.0.250.0090.00214.38
7.0.240.0110.00014.34
7.0.230.0120.00014.21
7.0.220.0060.00614.23
7.0.210.0080.00414.17
7.0.200.0040.00615.63
7.0.190.0060.00614.16
7.0.180.0090.00314.09
7.0.170.0120.00014.34
7.0.160.0060.00614.09
7.0.150.0120.00014.11
7.0.140.0060.03518.08
7.0.130.0120.00014.14
7.0.120.0060.00514.28
7.0.110.0110.00014.19
7.0.100.0090.00314.11
7.0.90.0100.00214.02
7.0.80.0060.00614.23
7.0.70.0110.04218.03
7.0.60.0040.03017.95
7.0.50.0090.04218.14
7.0.40.0060.04517.17
7.0.30.0070.03217.22
7.0.20.0040.04017.15
7.0.10.0090.04017.20
7.0.00.0030.03817.14
5.6.400.0040.00712.77
5.6.390.0060.00612.66
5.6.380.0080.00312.87
5.6.370.0080.00412.93
5.6.360.0070.00412.95
5.6.350.0080.00312.53
5.6.340.0090.00212.89
5.6.330.0100.00012.87
5.6.320.0070.00412.86
5.6.310.0090.00312.83
5.6.300.0060.00612.51
5.6.290.0110.00012.63
5.6.280.0070.03716.80
5.6.270.0080.00312.55
5.6.260.0110.00012.78
5.6.250.0120.00012.77
5.6.240.0060.00612.84
5.6.230.0120.00012.80
5.6.220.0100.04016.82
5.6.210.0040.04416.69
5.6.200.0090.03517.11
5.6.190.0100.03716.98
5.6.180.0120.03516.89
5.6.170.0130.03116.98
5.6.160.0080.04517.02
5.6.150.0080.03517.00
5.6.140.0110.02717.06
5.6.130.0060.04517.08
5.6.120.0060.04516.97
5.6.110.0090.04216.88
5.6.100.0040.03717.05
5.6.90.0050.02616.92
5.6.80.0040.04116.67
5.6.70.0060.03316.55
5.6.60.0060.04316.81
5.6.50.0100.04016.70
5.6.40.0040.02416.52
5.6.30.0060.04516.48
5.6.20.0080.04016.62
5.6.10.0080.04116.58
5.6.00.0060.03516.57
5.5.380.0120.00013.11
5.5.370.0100.00213.11
5.5.360.0070.04516.54
5.5.350.0060.04416.68
5.5.340.0130.03816.74
5.5.330.0060.02816.91
5.5.320.0090.03916.85
5.5.310.0060.04216.84
5.5.300.0080.04316.86
5.5.290.0050.03916.77
5.5.280.0040.02616.93
5.5.270.0080.02816.83
5.5.260.0070.02416.77
5.5.250.0090.04116.70
5.5.240.0060.03716.61
5.5.230.0080.04316.39
5.5.220.0130.03016.52
5.5.210.0090.03316.67
5.5.200.0060.03216.43
5.5.190.0070.02416.51
5.5.180.0060.04416.40
5.5.170.0050.00512.70
5.5.160.0060.04116.40
5.5.150.0070.04216.39
5.5.140.0050.03416.33
5.5.130.0040.04516.52
5.5.120.0110.03616.36
5.5.110.0070.04016.31
5.5.100.0030.03316.45
5.5.90.0080.03816.36
5.5.80.0050.02516.38
5.5.70.0100.02516.50
5.5.60.0110.02516.52
5.5.50.0080.03716.50
5.5.40.0040.03716.45
5.5.30.0050.04016.54
5.5.20.0060.03716.41
5.5.10.0080.03816.37
5.5.00.0040.04516.30
5.4.450.0120.03516.01
5.4.440.0060.04216.15
5.4.430.0070.03716.08
5.4.420.0030.04316.10
5.4.410.0050.02816.03
5.4.400.0040.04316.01
5.4.390.0070.02315.98
5.4.380.0050.03815.90
5.4.370.0050.02515.99
5.4.360.0060.04015.69
5.4.350.0050.04015.88
5.4.340.0080.04115.90
5.4.330.0090.00412.72
5.4.320.0040.03215.93
5.4.310.0040.02215.86
5.4.300.0110.03516.07
5.4.290.0060.02615.92
5.4.280.0090.03815.99
5.4.270.0100.02716.10
5.4.260.0090.03615.84
5.4.250.0030.02615.88
5.4.240.0030.03015.93
5.4.230.0090.03115.89
5.4.220.0040.04215.71
5.4.210.0110.03515.79
5.4.200.0060.03115.58
5.4.190.0080.02515.85
5.4.180.0080.02815.70
5.4.170.0060.04315.89
5.4.160.0060.04216.00
5.4.150.0080.03215.84
5.4.140.0080.03814.56
5.4.130.0080.03114.60
5.4.120.0100.03014.51
5.4.110.0090.03714.58
5.4.100.0050.02814.64
5.4.90.0060.02214.71
5.4.80.0070.01814.61
5.4.70.0090.01814.67
5.4.60.0020.04414.54
5.4.50.0080.03814.55
5.4.40.0060.03914.57
5.4.30.0060.03314.53
5.4.20.0050.02914.51
5.4.10.0100.03614.67
5.4.00.0040.03914.13
5.3.290.0040.02914.02
5.3.280.0030.04513.92
5.3.270.0060.04213.85
5.3.260.0060.04013.75
5.3.250.0080.02513.89
5.3.240.0110.03513.71
5.3.230.0070.02713.77
5.3.220.0040.02713.73
5.3.210.0060.04113.88
5.3.200.0080.03813.63
5.3.190.0060.04013.72
5.3.180.0060.03313.85
5.3.170.0110.03713.78
5.3.160.0080.01813.82
5.3.150.0050.02113.78
5.3.140.0070.03013.85
5.3.130.0050.04013.83
5.3.120.0040.04013.74
5.3.110.0040.04213.76
5.3.100.0090.03313.66
5.3.90.0100.03313.48
5.3.80.0090.03713.55
5.3.70.0020.03713.57
5.3.60.0040.04313.54
5.3.50.0020.03913.53
5.3.40.0030.03513.47
5.3.30.0090.02813.53
5.3.20.0030.04013.40
5.3.10.0090.02413.30
5.3.00.0060.03113.21
5.2.170.0030.02712.19
5.2.160.0040.03012.21
5.2.150.0040.03612.21
5.2.140.0050.03112.09
5.2.130.0080.03312.18
5.2.120.0060.03112.07
5.2.110.0060.03112.07
5.2.100.0040.02512.09
5.2.90.0060.03012.13
5.2.80.0090.03012.17
5.2.70.0020.03812.13
5.2.60.0070.03111.97
5.2.50.0070.03212.17
5.2.40.0050.03112.02
5.2.30.0070.03212.14
5.2.20.0050.02512.07
5.2.10.0050.01412.06
5.2.00.0050.01711.88
5.1.60.0060.01211.60
5.1.50.0070.01911.73
5.1.40.0040.01311.64
5.1.30.0030.03311.80
5.1.20.0030.01511.63
5.1.10.0040.01311.61
5.1.00.0020.01611.63
5.0.50.0020.01511.51
5.0.40.0030.01211.51
5.0.30.0030.02211.51
5.0.20.0030.01011.51
5.0.10.0030.01111.51
5.0.00.0020.03511.51
4.4.90.0030.01711.51
4.4.80.0020.01811.51
4.4.70.0020.01811.51
4.4.60.0020.01711.51
4.4.50.0000.01411.51
4.4.40.0020.01311.51
4.4.30.0000.01211.51
4.4.20.0000.01011.51
4.4.10.0020.00811.51
4.4.00.0010.01411.51
4.3.110.0020.00811.51
4.3.100.0030.00811.51
4.3.90.0000.00911.51
4.3.80.0030.01111.51
4.3.70.0000.00911.51
4.3.60.0020.00811.51
4.3.50.0000.01511.51
4.3.40.0010.01311.51
4.3.30.0000.01011.51
4.3.20.0020.00811.51
4.3.10.0010.00811.51
4.3.00.0010.00911.51

preferences:
49.57 ms | 401 KiB | 5 Q