3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * Example: Decode an Input Stream with PHP filters * * decode-input-stream-example.php * * @link https://gist.github.com/hakre/d34239bb237c50e728fd * @link http://stackoverflow.com/q/25051578/367456 */ # given a file which contains hex-encoded binary sequences that are partially disruped by US-ASCII control characters $transport = '<?xml version=\x221.0\x22 encoding=\x22UTF-8\x22?> \x0A<issues>\x0A\x09<issue id=\x225863\x22 found=\x221\x22>\xD0\x9F\xD0\xBE \xD0\xBD\xD0\xBE\xD0\xBC\xD0\xB5\xD1\x80\xD1\x83 \xD1\x81\xD1\x87\xD0\xB 5\xD1\x82\xD0\xB0 19479 \xD0\xBD\xD0\xB0\xD0\xB9\xD0\xB4\xD0\xB5\xD0\xBD\xD0\xBE:\x0A\xD0\x97\xD0\xB0\xD0\xBA\xD0\xB0\xD0\xB7 \xD0\xBF\xD0\xBE\xD0\xBA\xD1\x83\xD0\xBF\xD0\xB0\xD1\x82\xD0\xB5\xD0\xBB\xD1\x8F 0000015597 \xD0\xBE...</issue></issues>'; $file = 'data://text/plain;base64,' . base64_encode($transport); # registering two filters, one to remove control characters, the other to decode hex-sequences stream_filter_register('filter.controlchars', 'ControlCharsFilter'); stream_filter_register('decode.hexsequences', 'HexDecodeFilter'); # allows to chain those filters and to obtain the decoded (raw) data on-the-fly $filters = 'filter.controlchars/decode.hexsequences'; $xml = simplexml_load_file("php://filter/read=$filters/resource=" . $file); echo "isseu id: ", $xml->issue['id'], "\n"; $xml->asXML('php://stdout'); /** * Class ReadFilter */ abstract class ReadFilter extends php_user_filter { function filter($in, $out, &$consumed, $closing) { while ($bucket = stream_bucket_make_writeable($in)) { $bucket->data = $this->apply($bucket->data); $consumed += $bucket->datalen; stream_bucket_append($out, $bucket); } return PSFS_PASS_ON; } abstract function apply($string); } /** * Class ControlCharsFilter */ class ControlCharsFilter extends ReadFilter { function apply($string) { return preg_replace('~[\x00-\x1f]+~', '', $string); } } /** * Class HexDecodeFilter */ class HexDecodeFilter extends ReadFilter { function apply($string) { return preg_replace_callback( '/\\\\x([A-F0-9]{2})/i', 'self::decodeHexMatches' , $string ); } private static function decodeHexMatches($matches) { return hex2bin($matches[1]); } }

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.0090.00617.50
8.3.50.0080.01222.24
8.3.40.0090.00619.47
8.3.30.0070.00719.42
8.3.20.0040.00420.59
8.3.10.0080.00022.10
8.3.00.0030.00618.18
8.2.180.0160.00317.13
8.2.170.0150.00622.96
8.2.160.0070.00720.85
8.2.150.0030.00624.18
8.2.140.0060.00324.66
8.2.130.0040.00426.16
8.2.120.0040.00421.30
8.2.110.0060.00321.44
8.2.100.0120.00018.53
8.2.90.0040.00418.53
8.2.80.0070.00320.16
8.2.70.0060.00318.00
8.2.60.0080.00018.00
8.2.50.0030.00518.25
8.2.40.0060.00318.47
8.2.30.0000.00718.70
8.2.20.0000.00818.27
8.2.10.0000.00818.39
8.2.00.0050.00319.93
8.1.280.0060.01325.92
8.1.270.0030.00624.34
8.1.260.0050.00326.35
8.1.250.0000.00828.09
8.1.240.0100.00022.66
8.1.230.0090.00322.50
8.1.220.0000.00818.05
8.1.210.0050.00319.27
8.1.200.0030.00617.85
8.1.190.0080.00017.85
8.1.180.0060.00318.10
8.1.170.0030.00619.20
8.1.160.0040.00422.35
8.1.150.0000.00819.20
8.1.140.0080.00017.96
8.1.130.0050.00318.28
8.1.120.0000.00717.81
8.1.110.0040.00418.01
8.1.100.0050.00317.81
8.1.90.0000.00717.82
8.1.80.0040.00417.82
8.1.70.0030.00317.89
8.1.60.0000.00818.16
8.1.50.0000.00818.07
8.1.40.0080.00018.04
8.1.30.0030.00618.15
8.1.20.0000.00818.07
8.1.10.0000.00817.89
8.1.00.0040.00418.07
8.0.300.0050.00220.44
8.0.290.0000.00817.13
8.0.280.0000.00818.88
8.0.270.0020.00517.26
8.0.260.0030.00317.52
8.0.250.0000.00717.47
8.0.240.0080.00017.30
8.0.230.0000.00717.47
8.0.220.0030.00317.39
8.0.210.0000.00717.38
8.0.200.0000.00717.50
8.0.190.0060.00317.45
8.0.180.0000.00817.38
8.0.170.0040.00417.33
8.0.160.0040.00417.42
8.0.150.0050.00217.39
8.0.140.0080.00017.37
8.0.130.0030.00313.83
8.0.120.0030.00717.38
8.0.110.0080.00017.25
8.0.100.0050.00217.19
8.0.90.0070.00017.15
8.0.80.0130.00317.31
8.0.70.0040.00417.29
8.0.60.0070.00017.42
8.0.50.0040.00417.48
8.0.30.0180.00517.84
8.0.20.0140.00817.60
8.0.10.0000.00717.48
8.0.00.0050.01317.23
7.4.330.0030.00315.46
7.4.320.0060.00017.06
7.4.300.0030.00316.98
7.4.290.0070.00017.04
7.4.280.0040.00417.13
7.4.270.0040.00417.04
7.4.260.0030.00317.00
7.4.250.0000.00817.27
7.4.240.0020.00516.98
7.4.230.0050.00317.20
7.4.220.0110.00717.14
7.4.210.0120.00317.08
7.4.200.0000.01016.88
7.4.160.0170.00016.95
7.4.150.0090.00917.40
7.4.140.0070.01017.86
7.4.130.0100.00717.12
7.4.120.0130.00517.19
7.4.110.0110.00716.98
7.4.100.0080.01017.14
7.4.90.0120.00617.04
7.4.80.0000.01719.39
7.4.70.0080.01117.06
7.4.60.0090.00816.96
7.4.50.0030.00916.86
7.4.40.0060.01217.08
7.4.30.0100.00616.92
7.4.20.0100.01016.85
7.4.10.0090.00917.10
7.4.00.0080.00916.22
7.3.330.0040.00413.77
7.3.320.0000.00613.60
7.3.310.0000.00716.68
7.3.300.0030.00316.77
7.3.290.0090.00616.84
7.3.280.0060.01116.87
7.3.270.0040.01617.40
7.3.260.0110.00817.09
7.3.250.0130.00817.05
7.3.240.0120.00617.11
7.3.230.0090.01217.00
7.3.210.0130.01017.16
7.3.200.0070.01016.97
7.3.190.0070.01116.99
7.3.180.0070.01017.08
7.3.170.0100.00717.05
7.3.160.0080.00817.09
7.3.150.0070.01017.08
7.3.140.0120.01017.04
7.3.130.0030.01316.99
7.3.120.0050.01015.99
7.3.110.0040.01416.83
7.3.100.0160.00016.89
7.3.90.0030.01316.91
7.3.80.0100.01016.81
7.3.70.0060.01116.96
7.3.60.0070.01116.89
7.3.50.0090.00816.89
7.3.40.0130.00616.91
7.3.30.0130.00316.89
7.3.20.0110.01216.98
7.3.10.0120.01116.98
7.3.00.0150.00817.07
7.2.330.0100.00716.95
7.2.320.0150.01017.21
7.2.310.0070.01217.19
7.2.300.0120.00617.20
7.2.290.0150.00517.19
7.2.280.0110.00717.16
7.2.270.0170.00317.15
7.2.260.0120.01017.29
7.2.250.0030.01417.00
7.2.240.0150.00317.18
7.2.230.0100.01017.25
7.2.220.0100.00717.06
7.2.210.0150.00617.14
7.2.200.0070.01017.07
7.2.190.0030.01417.05
7.2.180.0130.00617.14
7.2.170.0060.01617.11
7.2.160.0110.00816.90
7.2.150.0140.01017.18
7.2.140.0100.01317.13
7.2.130.0120.00617.48
7.2.120.0090.00917.25
7.2.110.0070.01117.26
7.2.100.0110.01017.16
7.2.90.0090.00917.29
7.2.80.0110.00817.35
7.2.70.0080.01117.36
7.2.60.0030.01117.08
7.2.50.0130.00317.02
7.2.40.0290.00317.16
7.2.30.0170.00017.42
7.2.20.0110.00717.41
7.2.10.0100.01317.19
7.2.00.0200.00617.11
7.1.330.0080.00816.23
7.1.320.0090.00916.34
7.1.310.0070.01115.93
7.1.300.0120.00616.09
7.1.290.0040.01816.11
7.1.280.0130.00516.00
7.1.270.0080.00915.90
7.1.260.0150.00716.16
7.1.250.0110.00716.18
7.1.240.0070.01515.93
7.1.230.0040.01615.92
7.1.220.0060.01616.04
7.1.210.0170.00816.00
7.1.200.0070.01116.04
7.1.190.0150.00615.98
7.1.180.0180.00016.00
7.1.170.0090.00916.01
7.1.160.0120.00616.06
7.1.150.0090.01116.27
7.1.140.0130.01015.71
7.1.130.0090.01215.88
7.1.120.0380.01216.04
7.1.110.0120.00916.02
7.1.100.0060.00617.34
7.1.90.0100.00716.18
7.1.80.0100.01116.14
7.1.70.0060.00616.84
7.1.60.0110.00817.84
7.1.50.0130.01016.78
7.1.40.0110.00716.18
7.1.30.0140.00416.07
7.1.20.0000.01715.98
7.1.10.0720.01015.97
7.1.00.0090.03919.29
7.0.330.0170.00615.71
7.0.320.0140.01015.59
7.0.310.0190.00815.66
7.0.300.0140.01015.66
7.0.290.0170.00615.51
7.0.280.0090.01515.70
7.0.270.0160.00715.68
7.0.260.0080.01615.59
7.0.250.0100.01515.89
7.0.240.0210.00915.90
7.0.230.0170.01315.80
7.0.220.0210.01515.95
7.0.210.0140.01815.90
7.0.200.0210.00716.41
7.0.190.0190.00815.86
7.0.180.0220.00615.76
7.0.170.0190.00815.99
7.0.160.0200.00815.68
7.0.150.0170.00915.92
7.0.140.0120.04318.99
7.0.130.0150.01215.80
7.0.120.0170.01115.75
7.0.110.0180.00915.82
7.0.100.0140.04717.93
7.0.90.0310.04817.95
7.0.80.0140.02618.01
7.0.70.0120.04317.97
7.0.60.0050.05317.91
7.0.50.0310.02518.13
7.0.40.0130.04617.95
7.0.30.0140.02917.96
7.0.20.0120.03918.05
7.0.10.0140.02317.95
7.0.00.0140.02517.98
5.6.400.0220.00716.17
5.6.390.0090.01716.36
5.6.380.0150.01216.16
5.6.370.0100.01916.19
5.6.360.0170.00916.46
5.6.350.0190.00816.48
5.6.340.0140.01116.18
5.6.330.0190.01116.27
5.6.320.0140.01116.14
5.6.310.0190.01116.46
5.6.300.0140.01416.71
5.6.290.0220.00716.50
5.6.280.0150.03818.76
5.6.270.0140.01416.73
5.6.260.0210.00716.37
5.6.250.0150.04318.72
5.6.240.0140.04818.64
5.6.230.0180.03818.57
5.6.220.0110.04118.57
5.6.210.0130.03818.59
5.6.200.0160.02718.79
5.6.190.0140.04518.77
5.6.180.0140.04718.78
5.6.170.0140.04318.90
5.6.160.0200.02518.71
5.6.150.0210.04318.71
5.6.140.0210.03518.92
5.6.130.0210.02318.80
5.6.120.0140.04418.81
5.6.110.0110.02618.69
5.6.100.0090.02618.76
5.6.90.0070.03118.87
5.6.80.0080.02718.46
5.6.70.0110.04118.50
5.6.60.0130.04018.40
5.6.50.0150.04518.41
5.6.40.0110.04918.48
5.6.30.0110.02618.42
5.6.20.0140.03218.55
5.6.10.0150.03218.51
5.6.00.0100.02818.46
5.5.380.0180.04218.31
5.5.370.0210.02218.49
5.5.360.0070.06118.43
5.5.350.0180.04218.46
5.5.340.0120.03818.69
5.5.330.0180.02218.63
5.5.320.0150.03118.76
5.5.310.0130.04518.67
5.5.300.0160.03918.79
5.5.290.0160.04718.71
5.5.280.0120.02418.78
5.5.270.0170.03518.67
5.5.260.0100.02718.57
5.5.250.0120.04618.51
5.5.240.0140.02018.32
5.5.230.0170.04018.36
5.5.220.0120.03718.44
5.5.210.0200.04218.32
5.5.200.0140.04218.23
5.5.190.0090.02818.28
5.5.180.0140.04418.23
5.5.170.0200.00916.39
5.5.160.0100.02418.23
5.5.150.0140.04018.31
5.5.140.0100.02518.36
5.5.130.0060.03118.32
5.5.120.0080.03318.36
5.5.110.0130.03518.40
5.5.100.0140.04418.18
5.5.90.0140.02718.33
5.5.80.0130.03318.32
5.5.70.0130.03518.21
5.5.60.0140.02518.37
5.5.50.0130.04018.37
5.5.40.0100.03018.30
5.5.30.0200.03618.29
5.5.20.0160.04418.24
5.5.10.0140.04618.21
5.5.00.0090.02518.22
5.4.450.0100.04616.33
5.4.440.0100.04016.35
5.4.430.0080.02816.35
5.4.420.0090.02616.27
5.4.410.0140.03716.36
5.4.400.0120.03516.29
5.4.390.0090.03716.08
5.4.380.0120.04216.24
5.4.370.0070.03716.12
5.4.360.0160.01516.19
5.4.350.0140.03816.10
5.4.340.0120.02116.37
5.4.330.0100.01113.15
5.4.320.0040.03916.17
5.4.310.0130.02316.16
5.4.300.0090.02916.32
5.4.290.0100.03816.18
5.4.280.0060.02816.24
5.4.270.0110.04216.14
5.4.260.0110.04016.08
5.4.250.0100.03716.12
5.4.240.0090.02116.10
5.4.230.0110.03916.04
5.4.220.0110.04116.08
5.4.210.0080.02616.09
5.4.200.0080.04316.04
5.4.190.0140.02616.11
5.4.180.0160.02116.25
5.4.170.0110.02416.15
5.4.160.0120.02016.06
5.4.150.0210.03316.08
5.4.140.0100.03214.82
5.4.130.0090.01914.85
5.4.120.0080.02114.83
5.4.110.0090.02514.82
5.4.100.0100.02114.96
5.4.90.0090.03614.81
5.4.80.0070.02814.90
5.4.70.0110.02114.90
5.4.60.0100.03414.87
5.4.50.0090.03514.94
5.4.40.0040.02514.92
5.4.30.0090.03714.75
5.4.20.0130.02114.79
5.4.10.0060.02314.88
5.4.00.0110.03514.66
5.3.290.0140.03714.17
5.3.280.0190.03914.00
5.3.270.0110.02513.95
5.3.260.0120.04313.94
5.3.250.0090.04014.02
5.3.240.0110.04013.88
5.3.230.0070.02414.08
5.3.220.0140.03214.00
5.3.210.0110.02114.13
5.3.200.0070.03213.97
5.3.190.0060.02814.10
5.3.180.0100.03913.98
5.3.170.0140.03714.18
5.3.160.0100.02114.03
5.3.150.0070.02414.10
5.3.140.0160.03314.21
5.3.130.0100.02114.03
5.3.120.0130.02814.02
5.3.110.0100.03814.00
5.3.100.0110.02013.72
5.3.90.0080.03113.81
5.3.80.0140.01613.75
5.3.70.0100.04113.70
5.3.60.0070.02513.78
5.3.50.0090.03013.62
5.3.40.0150.03513.69
5.3.30.0090.03613.56
5.3.20.0040.04613.51
5.3.10.0080.04013.39
5.3.00.0090.04413.30
5.2.170.0090.02412.30
5.2.160.0060.03812.35
5.2.150.0080.02512.35
5.2.140.0050.04112.28
5.2.130.0100.03312.27
5.2.120.0110.03412.20
5.2.110.0050.02612.25
5.2.100.0150.02612.26
5.2.90.0110.02712.27
5.2.80.0050.03612.32
5.2.70.0100.03112.29
5.2.60.0120.01712.25
5.2.50.0050.03212.31
5.2.40.0040.03712.26
5.2.30.0120.03012.21
5.2.20.0020.02512.14
5.2.10.0050.02012.10
5.2.00.0000.03712.13
5.1.60.0000.02111.68
5.1.50.0070.02511.68
5.1.40.0040.02711.84
5.1.30.0090.02211.76
5.1.20.0090.02211.84
5.1.10.0120.01511.88
5.1.00.0040.03211.78
5.0.50.0020.02211.53
5.0.40.0020.02311.53
5.0.30.0060.03611.53
5.0.20.0100.01411.53
5.0.10.0030.02311.53
5.0.00.0050.02211.53
4.4.90.0030.01811.53
4.4.80.0020.02011.53
4.4.70.0040.01811.53
4.4.60.0080.01311.53
4.4.50.0030.01611.53
4.4.40.0030.02811.53
4.4.30.0050.01111.53
4.4.20.0050.01511.53
4.4.10.0030.02011.53
4.4.00.0050.02211.53
4.3.110.0040.01111.53
4.3.100.0040.00711.53
4.3.90.0050.01511.53
4.3.80.0030.01511.53
4.3.70.0040.01011.53
4.3.60.0040.01711.53
4.3.50.0030.01211.53
4.3.40.0050.02111.53
4.3.30.0060.01111.53
4.3.20.0020.01011.53
4.3.10.0040.00811.53
4.3.00.0030.00811.53

preferences:
46.68 ms | 401 KiB | 5 Q