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) . PHP_EOL; if ($i == count($rel_components)) return concat_path_components($copy); else return NULL; } var_dump(path_relative_to("/a/b/c", "/a/b"));

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.0110.01118.30
8.3.50.0160.00321.98
8.3.40.0180.00418.96
8.3.30.0090.01218.67
8.3.20.0050.00318.73
8.3.10.0040.00418.76
8.3.00.0040.00421.86
8.2.180.0080.01117.00
8.2.170.0110.00422.96
8.2.160.0040.01120.53
8.2.150.0050.00324.18
8.2.140.0060.00324.66
8.2.130.0080.00026.16
8.2.120.0060.00319.25
8.2.110.0050.00520.47
8.2.100.0120.00017.84
8.2.90.0040.00419.30
8.2.80.0080.00017.97
8.2.70.0080.00017.74
8.2.60.0040.00417.93
8.2.50.0030.00618.07
8.2.40.0030.00618.16
8.2.30.0030.00519.79
8.2.20.0000.00717.68
8.2.10.0050.00317.85
8.2.00.0050.00317.72
8.1.280.0060.00925.92
8.1.270.0040.00423.99
8.1.260.0090.00926.35
8.1.250.0090.00028.09
8.1.240.0030.00622.53
8.1.230.0070.00420.82
8.1.220.0080.00018.77
8.1.210.0040.00419.02
8.1.200.0100.00017.47
8.1.190.0050.00317.43
8.1.180.0050.00318.10
8.1.170.0090.00018.59
8.1.160.0070.00018.91
8.1.150.0040.00418.65
8.1.140.0000.00817.54
8.1.130.0030.00317.85
8.1.120.0030.00517.39
8.1.110.0040.00417.44
8.1.100.0070.00017.46
8.1.90.0000.00817.56
8.1.80.0070.00017.32
8.1.70.0000.00717.50
8.1.60.0020.00517.63
8.1.50.0050.00217.48
8.1.40.0030.00617.56
8.1.30.0030.00617.69
8.1.20.0030.00517.65
8.1.10.0000.00817.57
8.1.00.0000.00717.55
8.0.300.0040.00420.04
8.0.290.0030.00617.18
8.0.280.0050.00218.38
8.0.270.0080.00017.29
8.0.260.0070.00016.82
8.0.250.0040.00416.94
8.0.240.0060.00617.03
8.0.230.0000.00617.08
8.0.220.0000.00716.89
8.0.210.0060.00316.97
8.0.200.0040.00417.08
8.0.190.0030.00316.92
8.0.180.0040.00416.94
8.0.170.0000.00717.04
8.0.160.0000.00717.00
8.0.150.0030.00516.91
8.0.140.0050.00216.95
8.0.130.0040.00413.41
8.0.120.0000.00815.12
8.0.110.0050.00315.23
8.0.100.0020.00515.13
8.0.90.0030.00515.23
8.0.80.0060.00515.22
8.0.70.0020.00515.19
8.0.60.0040.00315.08
8.0.50.0020.00615.22
8.0.30.0020.01315.98
8.0.20.0070.01116.08
8.0.10.0070.00015.30
8.0.00.0060.00715.69
7.4.330.0030.00314.82
7.4.320.0060.00016.62
7.4.300.0070.00016.63
7.4.290.0070.00016.54
7.4.280.0070.00016.64
7.4.270.0030.00316.46
7.4.260.0060.00013.30
7.4.250.0030.00314.90
7.4.240.0020.00515.00
7.4.230.0060.00114.80
7.4.220.0050.01014.90
7.4.210.0030.01115.97
7.4.200.0000.00714.87
7.4.190.0030.00314.98
7.4.180.0070.00013.37
7.4.160.0090.00514.99
7.4.150.0070.00515.35
7.4.140.0070.00716.33
7.4.130.0080.00515.41
7.4.120.0090.00715.41
7.4.110.0070.00514.95
7.4.100.0020.01014.92
7.4.90.0130.00314.89
7.4.80.0060.00616.31
7.4.70.0050.00714.76
7.4.60.0050.00614.85
7.4.50.0040.00414.63
7.4.40.0060.00517.76
7.4.30.0030.00814.94
7.4.20.0030.00313.23
7.4.10.0050.00714.25
7.4.00.0040.00914.47
7.3.330.0050.00013.32
7.3.320.0000.00513.42
7.3.310.0050.00214.90
7.3.300.0000.00714.85
7.3.290.0010.01114.87
7.3.280.0020.01115.71
7.3.270.0060.00815.43
7.3.260.0060.00716.59
7.3.250.0050.01215.42
7.3.240.0090.00314.89
7.3.230.0030.00814.96
7.3.220.0000.00713.43
7.3.210.0100.00314.83
7.3.200.0070.00516.30
7.3.190.0030.01015.02
7.3.180.0060.00615.00
7.3.170.0040.00914.84
7.3.160.0060.00614.89
7.3.150.0000.00713.16
7.3.140.0050.00313.20
7.3.130.0050.00613.96
7.3.120.0030.01114.48
7.3.110.0070.00313.97
7.3.100.0030.00813.92
7.3.90.0020.01014.25
7.3.80.0060.00613.96
7.3.70.0030.00514.17
7.3.60.0080.00314.26
7.3.50.0060.00614.11
7.3.40.0030.00414.01
7.3.30.0000.00914.17
7.3.20.0020.00515.90
7.3.10.0030.00816.20
7.3.00.0060.00716.15
7.2.340.0070.00513.43
7.2.330.0090.00814.90
7.2.320.0090.00815.15
7.2.310.0090.00715.14
7.2.300.0110.00515.17
7.2.290.0090.00715.12
7.2.280.0130.00013.43
7.2.270.0130.00313.46
7.2.260.0110.00614.26
7.2.250.0070.00914.17
7.2.240.0060.00814.04
7.2.230.0050.01014.42
7.2.220.0060.00914.21
7.2.210.0140.00214.14
7.2.200.0070.00814.31
7.2.190.0090.00714.16
7.2.180.0070.00514.39
7.2.170.0100.00414.38
7.2.160.0040.00714.47
7.2.150.0090.00416.04
7.2.140.0090.00416.18
7.2.130.0090.00516.50
7.2.120.0100.00416.50
7.2.110.0070.00516.43
7.2.100.0090.00816.30
7.2.90.0080.00516.43
7.2.80.0050.00916.53
7.2.70.0090.00716.29
7.2.60.0070.00716.52
7.2.50.0080.00516.56
7.2.40.0080.00716.50
7.2.30.0080.00516.53
7.2.20.0030.01116.49
7.2.10.0110.00216.48
7.2.00.0070.00817.28
7.1.330.0070.00515.09
7.1.320.0050.00915.16
7.1.310.0050.00814.94
7.1.300.0060.00715.18
7.1.290.0090.00315.04
7.1.280.0060.00614.99
7.1.270.0080.00515.15
7.1.260.0090.00215.12
7.1.250.0040.00915.12
7.1.240.0100.00315.32
7.1.230.0030.01015.27
7.1.220.0080.00615.26
7.1.210.0090.00415.23
7.1.200.0070.00415.40
7.1.190.0040.00815.25
7.1.180.0030.00915.28
7.1.170.0040.00915.30
7.1.160.0100.00315.25
7.1.150.0070.00715.29
7.1.140.0080.00315.28
7.1.130.0090.00415.23
7.1.120.0090.00315.17
7.1.110.0080.00415.28
7.1.100.0070.00716.00
7.1.90.0080.00815.34
7.1.80.0040.00815.34
7.1.70.0090.00515.66
7.1.60.0050.01016.31
7.1.50.0070.00815.74
7.1.40.0070.00715.13
7.1.30.0080.00515.27
7.1.20.0090.00315.27
7.1.10.0080.00615.31
7.1.00.0090.01917.12
7.0.330.0080.00514.95
7.0.320.0040.00915.07
7.0.310.0080.00414.91
7.0.300.0100.00314.96
7.0.290.0050.00814.90
7.0.280.0060.00514.99
7.0.270.0070.00414.95
7.0.260.0060.00615.00
7.0.250.0030.00614.99
7.0.240.0050.00815.09
7.0.230.0100.00614.98
7.0.220.0070.00515.07
7.0.210.0080.00414.96
7.0.200.0060.00315.43
7.0.190.0100.00414.99
7.0.180.0070.00615.08
7.0.170.0060.00714.99
7.0.160.0020.00915.05
7.0.150.0060.00615.03
7.0.140.0060.02216.64
7.0.130.0070.00515.03
7.0.120.0080.00414.95
7.0.110.0060.00714.91
7.0.100.0070.00614.98
7.0.90.0080.00514.86
7.0.80.0080.00614.89
7.0.70.0050.01516.68
7.0.60.0060.01416.67
7.0.50.0060.01416.82
7.0.40.0080.01315.31
7.0.30.0060.01715.23
7.0.20.0070.01715.18
7.0.10.0040.02815.22
7.0.00.0080.02615.30
5.6.400.0070.00513.58
5.6.390.0070.00713.61
5.6.380.0020.00813.72
5.6.370.0050.00613.85
5.6.360.0080.00413.93
5.6.350.0060.00613.88
5.6.340.0050.00813.84
5.6.330.0080.00413.74
5.6.320.0020.00713.86
5.6.310.0090.00513.56
5.6.300.0090.00613.94
5.6.290.0030.01013.80
5.6.280.0060.02415.54
5.6.270.0080.00513.85
5.6.260.0050.00713.80
5.6.250.0060.00613.96
5.6.240.0060.00613.86
5.6.230.0030.01013.80
5.6.220.0030.01615.65
5.6.210.0070.01115.54
5.6.200.0040.01615.61
5.6.190.0060.01515.75
5.6.180.0060.01615.63
5.6.170.0040.01715.75
5.6.160.0080.01415.64
5.6.150.0070.01715.66
5.6.140.0050.01715.65
5.6.130.0080.02415.65
5.6.120.0080.01215.69
5.6.110.0050.02815.56
5.6.100.0050.02715.68
5.6.90.0090.02315.60
5.6.80.0060.02515.49
5.6.70.0070.01315.41
5.6.60.0060.02115.45
5.6.50.0050.01915.44
5.6.40.0060.01815.54
5.6.30.0080.01715.50
5.6.20.0080.02315.54
5.6.10.0060.02515.33
5.6.00.0050.02315.45
5.5.380.0070.00512.85
5.5.370.0070.00612.90
5.5.360.0060.01314.73
5.5.350.0050.01314.67
5.5.340.0060.01214.88
5.5.330.0090.01114.86
5.5.320.0050.01814.91
5.5.310.0080.01314.75
5.5.300.0060.02614.76
5.5.290.0060.02714.79
5.5.280.0050.01414.92
5.5.270.0050.02514.85
5.5.260.0030.02714.83
5.5.250.0060.02114.95
5.5.240.0060.02314.69
5.5.230.0060.02114.74
5.5.220.0070.01914.73
5.5.210.0040.01914.70
5.5.200.0070.02114.52
5.5.190.0050.02414.68
5.5.180.0070.02014.69
5.5.170.0060.00612.79
5.5.160.0060.02114.66
5.5.150.0090.02214.64
5.5.140.0050.02614.56
5.5.130.0060.02314.59
5.5.120.0080.02214.61
5.5.110.0060.01614.61
5.5.100.0080.01914.64
5.5.90.0050.02414.72
5.5.80.0040.02414.59
5.5.70.0050.02414.75
5.5.60.0060.02214.69
5.5.50.0050.02514.69
5.5.40.0060.01514.67
5.5.30.0050.02414.64
5.5.20.0060.02314.68
5.5.10.0030.02614.58
5.5.00.0040.02514.63
5.4.450.0070.01413.75
5.4.440.0060.02313.73
5.4.430.0030.02613.64
5.4.420.0080.02213.54
5.4.410.0080.02013.60
5.4.400.0060.01813.59
5.4.390.0070.02313.52
5.4.380.0070.02213.56
5.4.370.0050.02413.66
5.4.360.0060.02113.61
5.4.350.0040.02013.55
5.4.340.0080.02113.60
5.4.330.0050.00511.72
5.4.320.0050.02113.60
5.4.310.0080.02013.48
5.4.300.0040.02213.48
5.4.290.0060.01713.60
5.4.280.0050.02213.56
5.4.270.0060.01713.53
5.4.260.0070.02013.42
5.4.250.0040.01713.67
5.4.240.0040.01613.47
5.4.230.0070.01313.54
5.4.220.0050.02313.48
5.4.210.0040.02413.47
5.4.200.0070.02113.49
5.4.190.0080.01613.57
5.4.180.0030.01913.55
5.4.170.0070.01813.47
5.4.160.0080.01913.53
5.4.150.0070.01913.54
5.4.140.0070.01412.99
5.4.130.0050.02212.94
5.4.120.0080.01112.88
5.4.110.0030.02512.96
5.4.100.0060.01712.95
5.4.90.0040.01412.93
5.4.80.0040.02312.96
5.4.70.0050.01912.93
5.4.60.0020.02313.02
5.4.50.0030.02012.83
5.4.40.0040.02112.91
5.4.30.0060.02212.94
5.4.20.0060.01812.95
5.4.10.0050.01712.96
5.4.00.0050.02212.74
5.3.290.0050.02212.48
5.3.280.0050.02112.31
5.3.270.0060.02112.41
5.3.260.0040.02112.38
5.3.250.0050.02312.49
5.3.240.0030.02312.34
5.3.230.0040.02412.40
5.3.220.0050.01712.30
5.3.210.0040.01312.30
5.3.200.0050.01512.39
5.3.190.0030.01412.41
5.3.180.0060.01112.40
5.3.170.0010.02612.35
5.3.160.0040.02412.43
5.3.150.0040.02412.51
5.3.140.0050.01812.43
5.3.130.0050.02112.41
5.3.120.0040.02012.35
5.3.110.0050.01812.35
5.3.100.0050.01712.17
5.3.90.0020.02612.42
5.3.80.0050.02212.26
5.3.70.0050.02212.23
5.3.60.0030.02112.31
5.3.50.0040.02412.22
5.3.40.0040.02112.28
5.3.30.0080.01812.31
5.3.20.0030.02412.22
5.3.10.0060.01712.03
5.3.00.0040.02212.07
5.2.170.0020.02311.50
5.2.160.0040.02311.53
5.2.150.0020.02311.39
5.2.140.0030.02411.47
5.2.130.0040.01711.48
5.2.120.0040.02011.39
5.2.110.0070.01211.40
5.2.100.0060.01511.40
5.2.90.0030.01911.39
5.2.80.0050.02111.46
5.2.70.0050.02011.46
5.2.60.0040.02211.34
5.2.50.0030.02611.45
5.2.40.0050.02411.41
5.2.30.0050.02211.43
5.2.20.0040.02111.38
5.2.10.0060.02311.29
5.2.00.0030.02211.34
5.1.60.0060.01011.07
5.1.50.0060.01911.06
5.1.40.0060.01711.19
5.1.30.0040.02111.15
5.1.20.0020.01911.16
5.1.10.0040.01811.08
5.1.00.0040.02111.13
5.0.50.0000.01911.01
5.0.40.0020.01911.01
5.0.30.0010.01711.01
5.0.20.0040.01311.01
5.0.10.0010.01811.01
5.0.00.0050.02211.01
4.4.90.0010.01411.01
4.4.80.0020.01211.01
4.4.70.0020.00911.01
4.4.60.0020.00811.01
4.4.50.0020.00911.01
4.4.40.0020.01511.01
4.4.30.0030.01211.01
4.4.20.0020.01311.01
4.4.10.0010.00911.01
4.4.00.0020.01611.01
4.3.110.0010.01111.01
4.3.100.0030.00911.01
4.3.90.0010.01411.01
4.3.80.0030.01811.01
4.3.70.0040.01311.01
4.3.60.0020.01411.01
4.3.50.0020.00711.01
4.3.40.0020.01411.01
4.3.30.0010.00811.01
4.3.20.0000.01311.01
4.3.10.0030.00711.01
4.3.00.0020.01211.01

preferences:
64.15 ms | 401 KiB | 5 Q