3v4l.org

run code in 300+ PHP versions simultaneously
<?php class MyFilter extends php_user_filter { private $data = ''; public function filter($in, $out, &$consumed, $closing) { $return = PSFS_FEED_ME; // While input data is available, continue to read it. while ($bucket_in = stream_bucket_make_writeable($in)) { $this->data .= $bucket_in->data; $consumed += $bucket_in->datalen; // Process whole lines. while (preg_match('/(.*?)[\r\n]+(.*)/s', $this->data, $match) === 1) { list(, $data, $this->data) = $match; // Send this record output. $data = strrev($data) . PHP_EOL; $bucket_out = stream_bucket_new($this->stream, $data); $return = PSFS_PASS_ON; stream_bucket_append($out, $bucket_out); } } // Process the final line. if ($closing && $this->data !== '') { $data = strrev($this->data) . PHP_EOL; $bucket_out = stream_bucket_new($this->stream, $data); $return = PSFS_PASS_ON; stream_bucket_append($out, $bucket_out); } return $return; } } stream_filter_register('my-filter', 'MyFilter'); $input = "Line one\nLine two\nLine three"; $stream = fopen('data://text/plain,' . $input, 'r'); stream_filter_append($stream, 'my-filter'); $output = ''; while (!feof($stream)) { $output .= fread($stream, 16); } fclose($stream); echo $output;

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.00718.68
8.3.50.0090.00918.11
8.3.40.0040.01119.21
8.3.30.0130.00619.17
8.3.20.0000.00819.50
8.3.10.0070.00021.76
8.3.00.0040.00420.72
8.2.180.0070.01018.91
8.2.170.0140.00722.96
8.2.160.0100.00722.39
8.2.150.0000.00824.18
8.2.140.0000.00824.66
8.2.130.0080.00018.16
8.2.120.0090.00026.35
8.2.110.0030.00721.09
8.2.100.0060.00917.97
8.2.90.0000.00818.00
8.2.80.0060.00317.97
8.2.70.0040.00417.93
8.2.60.0040.00418.22
8.2.50.0000.00818.10
8.2.40.0090.00019.42
8.2.30.0070.00019.55
8.2.20.0000.00818.21
8.2.10.0000.00918.19
8.2.00.0060.00318.00
8.1.280.0230.00025.92
8.1.270.0060.00320.73
8.1.260.0080.00026.35
8.1.250.0000.00728.09
8.1.240.0090.00022.09
8.1.230.0090.00322.12
8.1.220.0050.00318.01
8.1.210.0030.00618.77
8.1.200.0030.00617.63
8.1.190.0030.00617.50
8.1.180.0100.00018.10
8.1.170.0000.00918.68
8.1.160.0030.00519.01
8.1.150.0030.00619.03
8.1.140.0000.00722.20
8.1.130.0050.00217.83
8.1.120.0000.00917.67
8.1.110.0060.00717.65
8.1.100.0080.00517.71
8.1.90.0080.00717.61
8.1.80.0140.00118.46
8.1.70.0070.00717.60
8.1.60.0130.00217.76
8.1.50.0140.00117.72
8.1.40.0100.00617.74
8.1.30.0100.00517.85
8.1.20.0140.00117.80
8.1.10.0110.00417.73
8.1.00.0080.00617.63
8.0.300.0040.00418.77
8.0.290.0030.00616.88
8.0.280.0000.00818.43
8.0.270.0050.00217.43
8.0.260.0000.00717.06
8.0.250.0090.00317.05
8.0.240.0070.00417.06
8.0.230.0070.00517.11
8.0.220.0060.00617.10
8.0.210.0060.00617.05
8.0.200.0090.00217.12
8.0.190.0070.00517.12
8.0.180.0090.00417.08
8.0.170.0090.00317.08
8.0.160.0060.00717.09
8.0.150.0060.00716.98
8.0.140.0050.00717.04
8.0.130.0060.00715.28
8.0.120.0080.00517.08
8.0.110.0030.00917.12
8.0.100.0100.00217.15
8.0.90.0100.00317.11
8.0.80.0100.00917.12
8.0.70.0070.00617.14
8.0.60.0080.00417.16
8.0.50.0050.00717.18
8.0.30.0110.01017.27
8.0.20.0150.00617.27
8.0.10.0140.00917.17
8.0.00.0140.00617.08
7.4.330.0040.00215.55
7.4.320.0050.00716.82
7.4.300.0100.00416.78
7.4.290.0020.01117.67
7.4.280.0080.00616.65
7.4.270.0090.00316.79
7.4.260.0110.00216.82
7.4.250.0100.00216.74
7.4.240.0070.00516.80
7.4.230.0080.00416.73
7.4.220.0080.00416.88
7.4.210.0100.00616.82
7.4.200.0070.00616.82
7.4.190.0150.00016.77
7.4.180.0170.00016.69
7.4.160.0090.00816.73
7.4.150.0180.00416.78
7.4.140.0120.00917.51
7.4.130.0120.00816.78
7.4.120.0110.00816.78
7.4.110.0180.01016.68
7.4.100.0090.01016.70
7.4.90.0140.00916.79
7.4.80.0100.00817.22
7.4.70.0090.00816.72
7.4.60.0110.00716.81
7.4.50.0070.01016.70
7.4.40.0080.00916.72
7.4.30.0070.01116.74
7.4.20.0110.00616.63
7.4.10.0090.00916.60
7.4.00.0140.00716.39
7.3.330.0100.00314.97
7.3.320.0060.00615.03
7.3.310.0120.00216.54
7.3.300.0120.00016.53
7.3.290.0050.00716.61
7.3.280.0110.00616.59
7.3.270.0150.00716.51
7.3.260.0140.00816.73
7.3.250.0170.00616.67
7.3.240.0120.00916.63
7.3.230.0190.00916.69
7.3.220.0150.00816.54
7.3.210.0100.00916.64
7.3.200.0130.00616.70
7.3.190.0080.00816.58
7.3.180.0110.00716.60
7.3.170.0120.00816.56
7.3.160.0130.01116.62
7.3.150.0130.00516.55
7.3.140.0080.01216.60
7.3.130.0090.01116.51
7.3.120.0090.01116.57
7.3.110.0120.00816.57
7.3.100.0100.00816.53
7.3.90.0090.00816.67
7.3.80.0120.00616.59
7.3.70.0100.00816.64
7.3.60.0120.00616.56
7.3.50.0070.01016.22
7.3.40.0090.01116.55
7.3.30.0150.00516.57
7.3.20.0100.01017.03
7.3.10.0100.00917.08
7.3.00.0080.01116.61
7.2.340.0120.01316.75
7.2.330.0170.00516.79
7.2.320.0170.01116.75
7.2.310.0110.01016.73
7.2.300.0130.00917.20
7.2.290.0120.01016.86
7.2.280.0150.00616.72
7.2.270.0180.00616.74
7.2.260.0140.00816.75
7.2.250.0190.00516.87
7.2.240.0160.00716.81
7.2.230.0100.01216.84
7.2.220.0110.01016.84
7.2.210.0120.00817.28
7.2.200.0200.00516.78
7.2.190.0130.01016.85
7.2.180.0170.00516.77
7.2.170.0140.00516.52
7.2.160.0130.01016.77
7.2.150.0130.01017.33
7.2.140.0160.00817.24
7.2.130.0130.00917.34
7.2.120.0130.01017.30
7.2.110.0150.00716.85
7.2.100.0160.00716.77
7.2.90.0160.00716.77
7.2.80.0150.00816.71
7.2.70.0140.00916.86
7.2.60.0130.00916.90
7.2.50.0320.00816.92
7.2.40.0190.00616.93
7.2.30.0200.00516.93
7.2.20.0170.00816.76
7.2.10.0180.00716.89
7.2.00.0150.00816.83
7.1.330.0240.00516.25
7.1.320.0160.01116.16
7.1.310.0200.01016.23
7.1.300.0190.00916.21
7.1.290.0210.00816.26
7.1.280.0200.00915.77
7.1.270.0230.00516.18
7.1.260.0190.00816.17
7.1.250.0170.00816.17
7.1.240.0170.00916.17
7.1.230.0210.00515.75
7.1.220.0140.01115.72
7.1.210.0190.00615.79
7.1.200.0180.00915.74
7.1.190.0180.00815.79
7.1.180.0190.00515.83
7.1.170.0290.01015.76
7.1.160.0190.00615.65
7.1.150.0180.00915.74
7.1.140.0200.01015.80
7.1.130.0210.00715.79
7.1.120.0210.00615.74
7.1.110.0200.00615.91
7.1.100.0180.01115.82
7.1.90.0160.00715.82
7.1.80.0170.00715.86
7.1.70.0260.00415.84
7.1.60.0220.01019.43
7.1.50.0230.00619.43
7.1.40.0340.00519.36
7.1.30.0240.00819.39
7.1.20.0210.00919.37
7.1.10.0200.00715.71
7.1.00.0210.00815.73
7.0.330.0240.00615.37
7.0.320.0140.01015.93
7.0.310.0180.00715.86
7.0.300.0220.00415.85
7.0.290.0160.01115.94
7.0.280.0210.00615.92
7.0.270.0220.00415.92
7.0.260.0150.01015.81
7.0.250.0160.01016.03
7.0.240.0210.00415.97
7.0.230.0170.00715.99
7.0.220.0180.00615.85
7.0.210.0180.00815.92
7.0.200.0150.00915.87
7.0.190.0190.00815.96
7.0.180.0210.00915.90
7.0.170.0180.00915.86
7.0.160.0160.01115.90
7.0.150.0160.01115.91
7.0.140.0220.00715.96
7.0.130.0210.00615.94
7.0.120.0210.00615.84
7.0.110.0190.00715.92
7.0.100.0180.00815.84
7.0.90.0190.00815.88
7.0.80.0150.01115.80
7.0.70.0180.00915.79
7.0.60.0190.00915.76
7.0.50.0200.00615.83
7.0.40.0200.00615.94
7.0.30.0290.00515.83
7.0.20.0190.00715.85
7.0.10.0180.00915.82
7.0.00.0210.00915.73
5.6.400.0170.00715.91
5.6.390.0180.00816.20
5.6.380.0150.00915.88
5.6.370.0180.00816.12
5.6.360.0180.01315.94
5.6.350.0180.00716.12
5.6.340.0210.00716.17
5.6.330.0160.01116.14
5.6.320.0190.00716.10
5.6.310.0180.00916.13
5.6.300.0190.00916.06
5.6.290.0170.00916.11
5.6.280.0180.01116.07
5.6.270.0200.00916.10
5.6.260.0180.00916.25
5.6.250.0220.00716.11
5.6.240.0180.00916.22
5.6.230.0180.01016.20
5.6.220.0230.00916.12
5.6.210.0220.00816.15
5.6.200.0180.01316.14
5.6.190.0190.00816.15
5.6.180.0180.00916.06
5.6.170.0160.01116.09
5.6.160.0160.00916.16
5.6.150.0200.00716.26
5.6.140.0190.00916.16
5.6.130.0210.00516.26
5.6.120.0200.00916.12
5.6.110.0190.01116.20
5.6.100.0210.01116.21
5.6.90.0180.00816.04
5.6.80.0180.00816.06
5.6.70.0160.00915.98
5.6.60.0220.00516.04
5.6.50.0150.01115.99
5.6.40.0180.00816.05
5.6.30.0190.00816.01
5.6.20.0170.00816.11
5.6.10.0200.00616.12
5.6.00.0170.00816.07

preferences:
65.79 ms | 401 KiB | 5 Q