3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * test that filemtime() returns Unix timestamp (UTC) on current system */ $nowHour = isset($_SERVER['REQUEST_TIME']) ? $_SERVER['REQUEST_TIME'] : time(); $hostname = php_uname('n'); $formatRfc = 'D, d M Y H:i:s O'; $timestampStartOfUnixEpoch = 0; // start of the Unix epoch. $timestampRequest = 3600 * (int)($nowHour / 3600); $testFile = sprintf('%s/%s', php_sys_get_temp_dir(), 'test-filemtime'); if ($hostname !== 'php_shell') { printf("PHP version is %s and OS is %s\n", PHP_VERSION, PHP_OS); } printf("Testfile is '%s'.\n", $testFile); touch($testFile, $timestampStartOfUnixEpoch); php_clearstatcache(false, $testFile); $mtime = filemtime($testFile); printf("Testfile '%s' mtime should be from touch %d, is %d.\n", basename($testFile), $timestampStartOfUnixEpoch, $mtime); printf("The mtime represents %s\n", date($formatRfc, $mtime)); touch($testFile, $timestampRequest); php_clearstatcache(false, $testFile); $mtime = filemtime($testFile); printf("Testfile '%s' mtime should be from touch %d, is %d.\n", basename($testFile), $timestampRequest, $mtime); printf("The mtime represents %s\n", date($formatRfc, $mtime)); unlink($testFile); /** * NOTE: This function is incomplete, the fallback is to '/tmp' which targets Unix-like. * * @return string */ function php_sys_get_temp_dir() { // (PHP 5 >= 5.2.1) if (function_exists('sys_get_temp_dir')) { return sys_get_temp_dir(); } // (PHP 4 >= 4.3.0, PHP 5) if (function_exists('stream_get_meta_data')) { $handle = tmpfile(); // (PHP 4, PHP 5) $meta = stream_get_meta_data($handle); // (PHP 5 >= 5.1.0) if (isset($meta['uri'])) { return dirname($meta['uri']); } } // emulate PHP 4 <= 4.0.6 tempnam() behavior, fragile foreach(array('TMPDIR', 'TMP') as $key) { if (isset($_ENV[$key])) { return $_ENV[$key]; } } // fallback for Unix-like (php_shell specifically) return '/tmp'; } /** * @param $clear_realpath_cache * @param $filename * @link http://php.net/manual/en/function.version-compare.php */ function php_clearstatcache($clear_realpath_cache, $filename) { if (version_compare(PHP_VERSION, '5.3.0') >= 0) { clearstatcache($clear_realpath_cache, $filename); } else { clearstatcache(); } }

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.0.120.0000.00713.41
8.0.110.0080.00013.46
8.0.100.0030.00313.39
8.0.90.0000.00713.50
8.0.80.0080.00013.54
8.0.70.0000.00613.42
8.0.60.0030.00313.41
8.0.50.0000.00813.51
8.0.30.0040.00413.37
8.0.20.0030.00513.47
8.0.10.0000.00713.51
8.0.00.0030.00613.56
7.4.250.0070.00013.25
7.4.240.0000.00613.32
7.4.230.0100.00013.38
7.4.220.0040.00413.22
7.4.210.0040.00413.35
7.4.200.0060.00313.31
7.4.190.0080.00013.39
7.4.180.0040.00413.43
7.4.160.0000.00813.32
7.4.150.0090.00013.32
7.4.140.0040.00413.27
7.4.130.0040.00413.25
7.4.120.0090.00013.23
7.4.110.0000.00913.30
7.4.100.0030.00613.31
7.4.90.0040.00413.37
7.4.80.0080.00313.24
7.4.70.0110.00313.27
7.4.60.0000.01113.17
7.4.50.0000.00813.20
7.4.40.0060.00613.12
7.4.30.0050.00513.30
7.4.20.0060.00613.23
7.4.10.0040.00813.21
7.4.00.0050.00513.22
7.3.310.0080.00013.44
7.3.300.0000.00813.52
7.3.290.0050.00513.39
7.3.280.0050.00513.44
7.3.270.0070.00413.28
7.3.260.0080.00013.38
7.3.250.0080.00313.44
7.3.240.0080.00413.30
7.3.230.0110.00013.24
7.3.220.0040.00813.34
7.3.210.0080.00313.32
7.3.200.0070.00413.22
7.3.190.0080.00413.16
7.3.180.0130.00013.17
7.3.170.0070.00313.23
7.3.160.0080.00513.31
7.3.150.0070.00213.32
7.3.140.0100.00013.16
7.3.130.0060.00013.32
7.3.120.0040.00714.14
7.3.110.0040.00813.95
7.3.100.0030.00914.11
7.3.90.0050.00714.31
7.3.80.0040.00614.13
7.3.70.0060.00514.10
7.3.60.0040.00714.27
7.3.50.0070.00714.18
7.3.40.0070.00514.19
7.3.30.0050.00514.11
7.3.20.0030.00916.05
7.3.10.0070.00516.38
7.3.00.0080.00716.28
7.2.340.0070.00713.24
7.2.330.0090.00613.44
7.2.320.0110.00313.41
7.2.310.0070.00713.23
7.2.300.0090.00413.42
7.2.290.0070.00713.43
7.2.280.0130.00013.41
7.2.270.0140.00013.38
7.2.260.0130.00013.41
7.2.250.0090.00613.27
7.2.240.0070.00614.39
7.2.230.0120.00314.36
7.2.220.0080.00714.27
7.2.210.0070.00514.10
7.2.200.0090.00314.33
7.2.190.0070.00514.16
7.2.180.0050.00714.29
7.2.170.0060.00614.39
7.2.160.0050.00914.45
7.2.150.0070.00616.08
7.2.140.0110.00416.19
7.2.130.0080.00816.58
7.2.120.0080.00616.54
7.2.110.0090.00516.48
7.2.100.0090.00816.62
7.2.90.0070.00816.55
7.2.80.0090.00716.57
7.2.70.0110.00516.51
7.2.60.0080.00916.56
7.2.50.0070.00816.42
7.2.40.0070.00716.65
7.2.30.0080.00716.56
7.2.20.0040.01016.54
7.2.10.0100.00716.62
7.2.00.0070.00617.20
7.1.330.0030.01015.11
7.1.320.0090.00415.18
7.1.310.0100.00315.04
7.1.300.0130.00115.18
7.1.290.0060.00814.93
7.1.280.0070.00815.07
7.1.270.0110.00415.28
7.1.260.0060.00814.97
7.1.250.0080.00715.42
7.1.240.0100.00314.35
7.1.230.0080.00614.48
7.1.220.0110.00314.51
7.1.210.0110.00314.50
7.1.200.0080.00515.15
7.1.190.0070.00714.45
7.1.180.0100.00414.39
7.1.170.0100.00314.32
7.1.160.0100.00314.28
7.1.150.0090.00314.28
7.1.140.0090.00614.54
7.1.130.0150.00014.44
7.1.120.0070.00814.47
7.1.110.0100.00314.42
7.1.100.0080.00716.21
7.1.90.0070.00714.22
7.1.80.0100.00314.32
7.1.70.0080.00315.88
7.1.60.0090.01116.82
7.1.50.0120.00815.71
7.1.40.0130.00014.33
7.1.30.0100.00314.48
7.1.20.0090.00514.30
7.1.10.0140.00014.31
7.1.00.0080.03818.50
7.0.330.0070.00714.00
7.0.320.0130.00014.10
7.0.310.0120.00014.05
7.0.300.0090.00414.23
7.0.290.0110.00414.24
7.0.280.0130.00014.22
7.0.270.0080.00514.31
7.0.260.0100.00314.23
7.0.250.0080.00814.27
7.0.240.0090.00314.47
7.0.230.0100.00314.34
7.0.220.0130.00014.41
7.0.210.0100.00314.31
7.0.200.0070.00415.47
7.0.190.0130.00214.45
7.0.180.0140.00014.52
7.0.170.0090.00614.40
7.0.160.0130.00014.30
7.0.150.0070.00614.33
7.0.140.0090.03718.11
7.0.130.0140.00014.09
7.0.120.0110.00214.32
7.0.110.0080.00414.21
7.0.100.0110.03717.16
7.0.90.0100.02517.05
7.0.80.0080.02917.11
7.0.70.0080.04217.08
7.0.60.0080.04317.10
7.0.50.0100.04217.22
7.0.40.0120.03917.18
7.0.30.0170.01817.24
7.0.20.0150.02717.16
7.0.10.0100.04317.14
7.0.00.0050.04117.21
5.6.400.0110.00313.05
5.6.390.0100.00313.07
5.6.380.0040.00912.92
5.6.370.0070.00712.96
5.6.360.0060.00612.80
5.6.350.0080.00513.07
5.6.340.0040.00912.75
5.6.330.0110.00212.76
5.6.320.0090.00513.07
5.6.310.0130.00013.05
5.6.300.0110.00312.83
5.6.290.0130.00012.93
5.6.280.0040.04016.91
5.6.270.0120.00012.90
5.6.260.0060.00612.96
5.6.250.0110.03216.90
5.6.240.0070.04316.88
5.6.230.0130.03816.85
5.6.220.0080.04216.83
5.6.210.0070.04416.77
5.6.200.0100.04016.97
5.6.190.0090.02817.02
5.6.180.0150.03817.19
5.6.170.0120.04316.89
5.6.160.0100.02517.15
5.6.150.0060.04717.14
5.6.140.0100.04016.95
5.6.130.0070.02717.00
5.6.120.0060.04917.02
5.6.110.0100.02616.89
5.6.100.0100.04216.91
5.6.90.0100.04017.05
5.6.80.0110.03816.66
5.6.70.0150.01716.62
5.6.60.0130.04016.71
5.6.50.0080.04316.56
5.6.40.0070.04216.61
5.6.30.0120.02216.64
5.6.20.0040.04116.54
5.6.10.0100.03316.54
5.6.00.0130.02016.67
5.5.380.0130.02016.72
5.5.370.0040.04516.63
5.5.360.0080.02516.52
5.5.350.0080.03816.64
5.5.340.0090.03116.73
5.5.330.0050.04016.70
5.5.320.0110.04116.65
5.5.310.0150.03016.78
5.5.300.0070.03116.62
5.5.290.0080.02316.76
5.5.280.0060.04816.92
5.5.270.0100.04216.83
5.5.260.0110.03816.67
5.5.250.0070.04616.72
5.5.240.0090.02916.59
5.5.230.0070.02316.52
5.5.220.0080.02816.58
5.5.210.0120.03816.56
5.5.200.0090.04016.40
5.5.190.0100.02516.40
5.5.180.0070.04016.47
5.5.170.0120.00012.89
5.5.160.0090.03316.50
5.5.150.0120.03616.38
5.5.140.0090.03516.36
5.5.130.0070.03016.48
5.5.120.0060.02716.43
5.5.110.0110.03516.28
5.5.100.0050.02416.51
5.5.90.0120.02816.64
5.5.80.0060.04016.58
5.5.70.0090.03316.44
5.5.60.0060.04216.51
5.5.50.0080.03816.38
5.5.40.0090.02716.47
5.5.30.0080.04116.51
5.5.20.0060.02516.48
5.5.10.0100.04016.55
5.5.00.0100.01816.42
5.4.450.0040.04916.07
5.4.440.0120.04016.01
5.4.430.0060.03015.94
5.4.420.0110.04016.16
5.4.410.0120.03816.14
5.4.400.0080.04315.75
5.4.390.0110.03315.80
5.4.380.0100.03815.71
5.4.370.0080.04015.80
5.4.360.0060.03015.79
5.4.350.0100.02615.79
5.4.340.0080.02315.84
5.4.330.0120.00012.67
5.4.320.0060.04315.97
5.4.310.0110.03815.96
5.4.300.0110.03815.90
5.4.290.0090.04015.97
5.4.280.0060.02515.83
5.4.270.0110.03415.97
5.4.260.0090.02315.94
5.4.250.0040.04115.85
5.4.240.0060.03715.79
5.4.230.0080.02015.66
5.4.220.0070.02515.74
5.4.210.0100.03815.84
5.4.200.0100.01815.92
5.4.190.0120.02515.86
5.4.180.0070.03815.70
5.4.170.0110.02215.91
5.4.160.0070.03916.01
5.4.150.0080.02815.88
5.4.140.0080.04114.59
5.4.130.0040.02214.67
5.4.120.0050.02314.49
5.4.110.0090.03714.64
5.4.100.0070.03714.63
5.4.90.0100.03814.55
5.4.80.0050.02514.69
5.4.70.0090.03814.81
5.4.60.0050.03214.61
5.4.50.0120.03214.51
5.4.40.0060.02814.65
5.4.30.0090.03814.75
5.4.20.0100.03214.61
5.4.10.0090.04014.63
5.4.00.0070.02714.22
5.3.290.0110.03713.94
5.3.280.0060.02313.83
5.3.270.0090.03813.96
5.3.260.0100.03814.05
5.3.250.0060.03613.99
5.3.240.0070.03213.93
5.3.230.0030.03813.92
5.3.220.0100.03013.83
5.3.210.0130.03513.91
5.3.200.0060.03113.88
5.3.190.0080.03813.99
5.3.180.0100.03213.90
5.3.170.0130.03313.91
5.3.160.0070.03414.02
5.3.150.0080.02313.94
5.3.140.0150.03313.80
5.3.130.0110.04113.85
5.3.120.0100.03813.90
5.3.110.0140.03613.80
5.3.100.0080.04013.53
5.3.90.0070.03213.62
5.3.80.0070.03713.56
5.3.70.0100.03613.62
5.3.60.0060.04113.48
5.3.50.0070.03713.63
5.3.40.0100.03213.57
5.3.30.0110.02213.60
5.3.20.0060.03913.34
5.3.10.0070.03913.33
5.3.00.0100.03713.21
5.2.170.0040.03411.58
5.2.160.0090.03111.78
5.2.150.0070.03111.64
5.2.140.0070.03311.60
5.2.130.0070.03211.60
5.2.120.0050.03311.66
5.2.110.0070.03211.67
5.2.100.0060.03311.65
5.2.90.0120.02811.63
5.2.80.0050.03411.61
5.2.70.0050.02811.54
5.2.60.0020.02111.48
5.2.50.0040.01911.47
5.2.40.0070.02611.40
5.2.30.0030.03011.55
5.2.20.0040.03111.36
5.2.10.0070.03011.44
5.2.00.0060.03111.30
5.1.60.0050.01510.36
5.1.50.0040.01410.43
5.1.40.0040.02710.62
5.1.30.0060.02810.90
5.1.20.0080.02710.81
5.1.10.0080.02010.64
5.1.00.0080.02210.62
5.0.50.0030.0259.57
5.0.40.0040.0159.47
5.0.30.0040.0329.41
5.0.20.0000.0199.38
5.0.10.0080.0169.34
5.0.00.0020.0329.34
4.4.90.0040.0178.76
4.4.80.0040.0108.76
4.4.70.0040.0078.76
4.4.60.0020.0188.76
4.4.50.0020.0178.76
4.4.40.0050.0128.76
4.4.30.0040.0158.76
4.4.20.0060.0118.76
4.4.10.0020.0188.76
4.4.00.0030.0248.76
4.3.110.0020.0188.76
4.3.100.0000.0178.76
4.3.90.0020.0188.76
4.3.80.0050.0278.76
4.3.70.0020.0158.76
4.3.60.0070.0108.76
4.3.50.0020.0188.76
4.3.40.0040.0258.76
4.3.30.0000.0208.76
4.3.20.0020.0188.76
4.3.10.0030.0178.76
4.3.00.0010.0178.76

preferences:
43.9 ms | 401 KiB | 5 Q