3v4l.org

run code in 300+ PHP versions simultaneously
<?php $txt = <<<TXT Line 1 Line 2 Line 3 Line 4 Line 5 Line 6 Line 7 Line 8 TXT; class FileObject extends SplFileObject { #[\ReturnTypeWillChange] public function seek($offset) { if ($offset < 0) { throw new Exception("Can't seek file: " . $this->getPathname() . " to negative offset: $offset"); } if ($offset === 0) { parent::seek(0); return; } $this->rewind(); for ($i = 0; $i < $offset; $i++) { $this->fgets(); $this->next(); if ($this->eof()) { break; } } //$this->current(); } } $file = new FileObject('php://memory', 'w+'); $file->fwrite($txt); echo 'Seeking line 2...', PHP_EOL; $file->seek(1); echo 'Position in the file: ', $file->ftell(), PHP_EOL; echo 'Rest of the file: ', PHP_EOL, $file->fread(5000); echo PHP_EOL, '-------------', PHP_EOL; echo 'Seeking line last line...', PHP_EOL; $file->seek(PHP_INT_MAX); $lastLine = $file->key(); $offset = max($lastLine - 1, 0); $file->seek($offset); echo 'Position in the file: ', $file->ftell(), PHP_EOL; echo 'Rest of the file: ', PHP_EOL, $file->fread(5000);

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.1.20.0040.00417.65
8.1.10.0190.00617.55
8.1.00.0170.00717.51
8.0.140.0120.00316.81
8.0.130.0160.00516.85
8.0.120.0170.00416.91
8.0.110.0150.00616.87
8.0.100.0180.00316.81
8.0.90.0150.00616.78
8.0.80.0160.00616.90
8.0.70.0170.00516.81
8.0.60.0190.00316.88
8.0.50.0150.00716.75
8.0.30.0130.00716.87
8.0.20.0150.00516.99
8.0.10.0170.00517.06
8.0.00.0060.00417.01
7.4.270.0140.00116.55
7.4.260.0220.00216.45
7.4.250.0230.00016.48
7.4.240.0190.00416.52
7.4.230.0160.00316.50
7.4.220.0160.00416.53
7.4.210.0140.00616.54
7.4.200.0150.00516.52
7.4.190.0160.00416.58
7.4.180.0120.00916.59
7.4.160.0140.00716.59
7.4.150.0150.00416.45
7.4.140.0110.01016.46
7.4.130.0150.00516.47
7.4.120.0150.00216.44
7.4.110.0170.00116.37
7.4.100.0110.00816.51
7.4.90.0160.00516.47
7.4.80.0140.00616.40
7.4.70.0160.00316.43
7.4.60.0150.00216.37
7.4.50.0130.00516.31
7.4.40.0150.00416.37
7.4.30.0110.00716.37
7.4.20.0130.00616.42
7.4.10.0160.00216.43
7.4.00.0130.00616.44
7.3.330.0170.00416.40
7.3.320.0180.00416.46
7.3.310.0180.00316.38
7.3.300.0130.00316.47
7.3.290.0150.00316.52
7.3.280.0120.00516.49
7.3.270.0170.00016.49
7.3.260.0120.00516.38
7.3.250.0180.00216.38
7.3.240.0160.00416.36
7.3.230.0110.00616.28
7.3.220.0120.00516.32
7.3.210.0120.00616.33
7.3.200.0110.00716.33
7.3.190.0140.00516.41
7.3.180.0160.00316.43
7.3.170.0140.00616.37
7.3.160.0170.00516.32
7.3.150.0110.00616.36
7.3.140.0110.00616.38
7.3.130.0100.00916.40
7.3.120.0150.00516.23
7.3.110.0170.00416.38
7.3.100.0120.00716.18
7.3.90.0180.00416.48
7.3.80.0140.00916.29
7.3.70.0140.00716.35
7.3.60.0120.00816.46
7.3.50.0190.00016.26
7.3.40.0150.00416.48
7.3.30.0210.00016.37
7.3.20.0150.00418.39
7.3.10.0180.00418.17
7.3.00.0200.00318.16
7.2.340.0120.00916.34
7.2.330.0140.00616.34
7.2.320.0130.00616.50
7.2.310.0130.00616.50
7.2.300.0190.00016.30
7.2.290.0160.00516.27
7.2.280.0210.00016.48
7.2.270.0190.00316.33
7.2.260.0140.00816.31
7.2.250.0200.00016.45
7.2.240.0170.00516.53
7.2.230.0200.00016.30
7.2.220.0180.00416.48
7.2.210.0160.00616.34
7.2.200.0160.00516.46
7.2.190.0170.00316.33
7.2.180.0160.00416.60
7.2.170.0150.00616.66
7.2.160.0160.00316.66
7.2.150.0200.00018.43
7.2.140.0160.00318.42
7.2.130.0160.00618.35
7.2.120.0160.00318.50
7.2.110.0120.00818.46
7.2.100.0170.00418.60
7.2.90.0160.00418.33
7.2.80.0180.00318.53
7.2.70.0210.00018.33
7.2.60.0100.01018.38
7.2.50.0180.00318.25
7.2.40.0110.00918.39
7.2.30.0170.00318.43
7.2.20.0180.00418.35
7.2.10.0170.00318.55
7.2.00.0200.00018.55
7.1.330.0170.00317.35
7.1.320.0120.00717.35
7.1.310.0150.00517.52
7.1.300.0190.00017.26
7.1.290.0190.00017.26
7.1.280.0130.00617.21
7.1.270.0110.00817.43
7.1.260.0140.00517.43
7.1.250.0140.00717.16
7.1.240.0180.00017.28
7.1.230.0180.00017.31
7.1.220.0130.00517.19
7.1.210.0200.00017.41
7.1.200.0140.00617.34
7.1.190.0110.00817.25
7.1.180.0070.01217.35
7.1.170.0140.00717.21
7.1.160.0070.01317.13
7.1.150.0120.00817.25
7.1.140.0140.00517.32
7.1.130.0180.00417.29
7.1.120.0110.00917.35
7.1.110.0190.00317.30
7.1.100.0140.00517.38
7.1.90.0150.00417.33
7.1.80.0200.00017.31
7.1.70.0110.00817.14
7.1.60.0190.00017.38
7.1.50.0080.01117.14
7.1.40.0150.00417.38
7.1.30.0140.00717.28
7.1.20.0200.00017.10
7.1.10.0180.00417.42
7.1.00.0150.00417.11
7.0.330.0180.00016.90
7.0.320.0140.00416.95
7.0.310.0170.00316.85
7.0.300.0150.00316.85
7.0.290.0110.00617.20
7.0.280.0120.00517.03
7.0.270.0090.00916.92
7.0.260.0110.00616.90
7.0.250.0100.01017.12
7.0.240.0170.00017.20
7.0.230.0170.00217.23
7.0.220.0140.00417.09
7.0.210.0160.00416.93
7.0.200.0180.00017.05
7.0.190.0150.00417.02
7.0.180.0180.00017.19
7.0.170.0190.00017.13
7.0.160.0100.01016.96
7.0.150.0190.00017.09
7.0.140.0150.00417.11
7.0.130.0140.00517.16
7.0.120.0150.00716.98
7.0.110.0160.00217.16
7.0.100.0070.01016.85
7.0.90.0150.00317.03
7.0.80.0190.00016.97
7.0.70.0120.00617.01
7.0.60.0120.00717.11
7.0.50.0140.00516.94
7.0.40.0130.00616.84
7.0.30.0150.00417.14
7.0.20.0160.00416.98
7.0.10.0140.00517.04
7.0.00.0150.00416.99
5.6.400.0140.00515.98
5.6.390.0070.01015.97
5.6.380.0110.00715.84
5.6.370.0150.00415.71
5.6.360.0120.00515.98
5.6.350.0100.00715.84
5.6.340.0150.00315.93
5.6.330.0140.00315.91
5.6.320.0150.00315.62
5.6.310.0130.00615.76
5.6.300.0120.00615.79
5.6.290.0190.00015.95
5.6.280.0180.00015.95
5.6.270.0180.00015.82
5.6.260.0140.00315.86
5.6.250.0120.00615.75
5.6.240.0120.00615.81
5.6.230.0100.00815.94
5.6.220.0180.00315.94
5.6.210.0090.00915.97
5.6.200.0140.00516.13
5.6.190.0150.00415.90
5.6.180.0110.00715.84
5.6.170.0150.00416.03
5.6.160.0170.00016.01
5.6.150.0110.00715.95
5.6.140.0190.00015.95
5.6.130.0110.00816.00
5.6.120.0170.00015.86
5.6.110.0140.00416.00
5.6.100.0110.00715.88
5.6.90.0130.00515.93
5.6.80.0180.00015.66
5.6.70.0180.00016.06
5.6.60.0140.00415.99
5.6.50.0140.00415.68
5.6.40.0090.00915.77
5.6.30.0120.00615.89
5.6.20.0140.00315.60
5.6.10.0090.00915.67
5.6.00.0080.00815.66
5.5.380.0120.00415.97
5.5.370.0110.00815.97
5.5.360.0060.01215.65
5.5.350.0140.00315.86
5.5.340.0180.00515.74
5.5.330.0110.00715.73
5.5.320.0140.00315.72
5.5.310.0120.00515.69
5.5.300.0140.00415.75
5.5.290.0070.01115.80
5.5.280.0110.00615.65
5.5.270.0180.00015.65
5.5.260.0150.00315.89
5.5.250.0070.01015.92
5.5.240.0130.00515.84
5.5.230.0120.00415.81
5.5.220.0120.00415.81
5.5.210.0140.00316.05
5.5.200.0100.00715.88
5.5.190.0090.00615.86
5.5.180.0130.00415.58
5.5.170.0140.00415.77
5.5.160.0140.00315.84
5.5.150.0120.00415.73
5.5.140.0120.00415.49
5.5.130.0110.00515.48
5.5.120.0200.00015.61
5.5.110.0170.00015.61
5.5.100.0120.00615.89
5.5.90.0170.00015.86
5.5.80.0120.00615.70
5.5.70.0130.00315.93
5.5.60.0190.00016.01
5.5.50.0140.00315.77
5.5.40.0120.00415.80
5.5.30.0100.00515.94
5.5.20.0130.00316.01
5.5.10.0110.00515.85
5.5.00.0120.00615.60
5.4.450.0120.00412.66
5.4.440.0070.00712.51
5.4.430.0120.00312.49
5.4.420.0130.00312.84
5.4.410.0130.00012.68
5.4.400.0110.00212.63
5.4.390.0000.01212.77
5.4.380.0100.00412.50
5.4.370.0140.00012.61
5.4.360.0070.00712.67
5.4.350.0120.00312.70
5.4.340.0140.00012.48
5.4.330.0040.00912.41
5.4.320.0130.00312.66
5.4.310.0110.00312.75
5.4.300.0110.00312.68
5.4.290.0050.00812.46
5.4.280.0100.00512.55
5.4.270.0120.00312.56
5.4.260.0150.00012.39
5.4.250.0110.00412.47
5.4.240.0110.00412.47
5.4.230.0070.00712.56
5.4.220.0070.00712.54
5.4.210.0160.00012.65
5.4.200.0100.00512.29
5.4.190.0090.00512.35
5.4.180.0100.00512.47
5.4.170.0080.00812.60
5.4.160.0120.00312.39
5.4.150.0130.00012.39
5.4.140.0120.00312.53
5.4.130.0130.00012.73
5.4.120.0110.00412.73
5.4.110.0130.00012.72
5.4.100.0140.00012.88
5.4.90.0120.00012.51
5.4.80.0090.00212.79
5.4.70.0100.00312.87
5.4.60.0130.00012.60
5.4.50.0090.00512.68
5.4.40.0120.00012.75
5.4.30.0110.00412.63
5.4.20.0090.00512.95
5.4.10.0090.00612.65
5.4.00.0040.00812.42
5.3.290.0110.00513.30
5.3.280.0110.00412.86
5.3.270.0110.00412.95
5.3.260.0110.00413.06
5.3.250.0110.00312.96
5.3.240.0050.01012.82
5.3.230.0120.00413.02
5.3.220.0110.00313.05
5.3.210.0070.00713.10
5.3.200.0090.00612.84
5.3.190.0110.00312.95
5.3.180.0100.00313.19
5.3.170.0110.00413.23
5.3.160.0090.00613.07
5.3.150.0160.00013.23
5.3.140.0110.00413.16
5.3.130.0140.00013.01
5.3.120.0090.00513.21
5.3.110.0130.00013.15
5.3.100.0130.00012.96
5.3.90.0110.00413.29
5.3.80.0100.00512.94
5.3.70.0070.00712.89
5.3.60.0120.00212.99
5.3.50.0120.00313.14
5.3.40.0140.00012.99
5.3.30.0110.00413.21
5.3.20.0070.00712.92
5.3.10.0080.00512.69
5.3.00.0090.00312.93
5.2.170.0060.00611.89
5.2.160.0030.00712.20
5.2.150.0120.00011.93
5.2.140.0110.00011.88
5.2.130.0110.00011.88
5.2.120.0080.00311.91
5.2.110.0060.00611.90
5.2.100.0100.00312.13
5.2.90.0080.00411.91
5.2.80.0080.00412.02
5.2.70.0120.00012.02
5.2.60.0060.00611.75
5.2.50.0060.00612.05
5.2.40.0120.00011.85
5.2.30.0060.00611.80
5.2.20.0070.00511.73
5.2.10.0060.00611.58
5.2.00.0130.00011.81
5.1.60.0040.00811.06
5.1.50.0100.00010.89
5.1.40.0050.00511.29
5.1.30.0040.00711.04
5.1.20.0100.00010.94
5.1.10.0110.00011.14
5.1.00.0060.00411.01
5.0.50.0000.00810.39
5.0.40.0000.00910.39
5.0.30.0060.00310.39
5.0.20.0090.00010.39
5.0.10.0080.00010.39
5.0.00.0070.00010.39
4.4.90.0030.00210.39
4.4.80.0050.00010.39
4.4.70.0050.00010.39
4.4.60.0040.00010.39
4.4.50.0000.00510.39
4.4.40.0050.00010.39
4.4.30.0030.00210.39
4.4.20.0050.00010.39
4.4.10.0020.00410.39
4.4.00.0050.00010.39
4.3.110.0050.00010.39
4.3.100.0050.00010.39
4.3.90.0050.00010.39
4.3.80.0050.00010.39
4.3.70.0000.00510.39
4.3.60.0050.00010.39
4.3.50.0030.00210.39
4.3.40.0050.00010.39
4.3.30.0000.00410.39
4.3.20.0040.00010.39
4.3.10.0030.00010.39
4.3.00.0000.00310.39

preferences:
16.65 ms | 455 KiB | 5 Q