3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * View any string as a hexdump. * * This is most commonly used to view binary data from streams * or sockets while debugging, but can be used to view any string * with non-viewable characters. * * @version 1.3.2 * @author Aidan Lister <aidan@php.net> * @author Peter Waller <iridum@php.net> * @link http://aidanlister.com/2004/04/viewing-binary-data-as-a-hexdump-in-php/ * @param string $data The string to be dumped * @param bool $htmloutput Set to false for non-HTML output * @param bool $uppercase Set to true for uppercase hex * @param bool $return Set to true to return the dump */ function hexdump ($data, $htmloutput = false, $uppercase = false, $return = true) { // Init $hexi = ''; $ascii = ''; $dump = ($htmloutput === true) ? '<pre>' : ''; $offset = 0; $len = strlen($data); // Upper or lower case hexadecimal $x = ($uppercase === false) ? 'x' : 'X'; // Iterate string for ($i = $j = 0; $i < $len; $i++) { // Convert to hexidecimal $hexi .= sprintf("%02$x ", ord($data[$i])); // Replace non-viewable bytes with '.' if (ord($data[$i]) >= 32) { $ascii .= ($htmloutput === true) ? htmlentities($data[$i]) : $data[$i]; } else { $ascii .= '.'; } // Add extra column spacing if ($j === 7) { $hexi .= ' '; $ascii .= ' '; } // Add row if (++$j === 16 || $i === $len - 1) { // Join the hexi / ascii output $dump .= sprintf("%04$x %-49s %s", $offset, $hexi, $ascii); // Reset vars $hexi = $ascii = ''; $offset += 16; $j = 0; // Add newline if ($i !== $len - 1) { $dump .= "\n"; } } } // Finish dump $dump .= $htmloutput === true ? '</pre>' : ''; $dump .= "\n"; // Output method if ($return === false) { echo $dump; } else { return $dump; } } $row=array_fill(0,256*4,'U'); $mem_map=array_fill(0,100,$row); $output=""; $mypic=imagecreate(100,100); $mycolor=imagecolorallocate($mypic,4,5,6); $mycolor2=imagecolorallocate($mypic,0x111,0x111,0x111); imagefill($mypic,0,0,$mycolor2); $pic_map=array_fill(0,100,$mypic); for ($x=0;$x<256*60;$x++){ //Each x is 1 index $cur_row=(int)($x/256); $offset=($x%256)*4; //if($offset!=0)die("offset not zero"); //print "True color image[b4] =" . (imageistruecolor($mypic)) ."\n"; //$mypic2=imagerotate($mypic,30,256*13 + $x); //$mypic2=imagerotate($pic_map[$cur_row],30,$x); $mypic2=imagerotate($mypic,30, $x); // Byte @ 0 $mem_map[$cur_row+2][$offset]=imagecolorat($mypic2,0,0)&0xFF; //echo "Row[$cur_row]-byte0\n"; //byte @ pos 1 if ($mem_map[$cur_row+1][$offset]!=='U'){ $Green=$mem_map[$cur_row+1][$offset]; $byte=(imagecolorat($mypic2,0,0)&0xFF00)>>8; if($Green > $byte) $byte=$byte|0x100; $mem_map[$cur_row+2][$offset+1]=($byte-$Green); //echo "Row[$cur_row]-byte1\n"; } else{ //echo "!=Row[$cur_row][$offset]=" . $mem_map[$cur_row+1][$offset]."\n"; } //Byte @ POS 2 if(($mem_map[$cur_row+1][$offset+1]!=='U')&&($mem_map[$cur_row][$offset]!=='U')){ $Green=$mem_map[$cur_row+1][$offset+1]; $Red=$mem_map[$cur_row][$offset]; //if($cur_row==20){ echo "ROW20: RED=$Red , Green=$Green Byte=$byte"}; $byte=(imagecolorat($mypic2,0,0)>>16) &0xFF; //if($cur_row==39){ echo "ROW20: RED=$Red , Green=$Green Byte=$byte \n";} if($Green > $byte) $byte=$byte|0x100; $byte=$byte-$Green; if($Red > $byte) $byte=$byte|0x100; $byte=$byte-$Red; $OF_Flag=(($mem_map[$cur_row+1][$offset] + $mem_map[$cur_row+2][$offset+1])>0xff)?1:0; $mem_map[$cur_row+2][$offset+2]=$byte - $OF_Flag; //echo "Row[$cur_row]-byte2\n"; //var_dump($mem_map); //die("post2die row=$cur_row"); // if($cur_row==39){echo "Row20:FinalBye=$byte\n";} //hexdump(chr($mem_map[$cur_row+2][$offset]).chr($mem_map[$cur_row+2][$offset+1]).chr($mem_map[$cur_row+2][$offset+2])); } //Byte @ POS 3 if(($mem_map[$cur_row+1][$offset+2]!=='U')&&($mem_map[$cur_row][$offset+1]!=='U')){ $Green=$mem_map[$cur_row+1][$offset+2]; $Red=$mem_map[$cur_row][$offset+1]; $byte=(imagecolorat($mypic2,0,0)&0xFF000000)>>24; if($Green > $byte) $byte=$byte|0x100; $byte=$byte-$Green; if($Red > $byte) $byte=$byte|0x100; $byte=$byte-$Red; $OF_Flag=(($mem_map[$cur_row][$offset] + $mem_map[$cur_row+1][$offset+1] + $mem_map[$cur_row+2][$offset+2])>>8)&0xFF; $mem_map[$cur_row+2][$offset+3]=$byte -$OF_Flag; //print "Current row = $cur_row\nCurrent offset =$offset"; //hexdump(chr($mem_map[$cur_row+2][$offset]).chr($mem_map[$cur_row+2][$offset+1]).chr($mem_map[$cur_row+2][$offset+2]).chr($mem_map[$cur_row+2][$offset+3])); } //var_dump(imagecolorat($mypic,0,0)); //echo "color @ 50,50 :" . dechex(imagecolorat($mypic,50,50)) . "\n"; //var_dump(imagecolorat($mypic,99,99)); imagedestroy($mypic); $mypic=imagecreate(100,100); imagefill($mypic,0,0,$mycolor2); } echo "done!\n"; //var_dump($mem_map); $output=""; foreach($mem_map as $row){ foreach($row as $byte){ $output.=chr($byte); } } for($count=0;$count<strlen($output);$count++){ if ($count%4 !=3) continue; $byte=ord($output[$count]); $Alpha=ord($output[$count+4156-3]); if($Alpha >$byte)$byte=$byte|0x100; $output[$count]=chr($byte-$Alpha); } echo hexdump($output); //file_put_contents("gdHex.dump",hexdump($output)); //var_dump(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.40.0160.00019.00
8.3.30.0090.00918.76
8.3.20.0030.00620.20
8.3.10.0050.00323.55
8.3.00.0050.00319.88
8.2.170.0060.00922.96
8.2.160.0140.00020.42
8.2.150.0000.00824.18
8.2.140.0060.00324.66
8.2.130.0030.00521.01
8.2.120.0030.00526.35
8.2.110.0100.00019.28
8.2.100.0090.00317.91
8.2.90.0090.00019.12
8.2.80.0050.00317.97
8.2.70.0000.00817.63
8.2.60.0060.00317.93
8.2.50.0040.00418.07
8.2.40.0000.00821.14
8.2.30.0000.00720.66
8.2.20.0050.00317.80
8.2.10.0040.00418.17
8.2.00.0020.00518.29
8.1.270.0040.00418.95
8.1.260.0040.00428.09
8.1.250.0050.00328.09
8.1.240.0030.00621.31
8.1.230.0080.00417.45
8.1.220.0040.00417.79
8.1.210.0040.00418.77
8.1.200.0060.00617.48
8.1.190.0060.00317.52
8.1.180.0050.00318.10
8.1.170.0000.00818.71
8.1.160.0040.00420.89
8.1.150.0020.00518.90
8.1.140.0040.00419.54
8.1.130.0000.00717.67
8.1.120.0000.00717.45
8.1.110.0000.00717.59
8.1.100.0030.00517.45
8.1.90.0040.00417.49
8.1.80.0050.00317.50
8.1.70.0040.00417.52
8.1.60.0030.00617.65
8.1.50.0030.00617.66
8.1.40.0060.00317.68
8.1.30.0000.00817.77
8.1.20.0000.00817.77
8.1.10.0000.00817.75
8.1.00.0090.00017.68
8.0.300.0060.00318.77
8.0.290.0070.00016.75
8.0.280.0000.00718.55
8.0.270.0100.00017.22
8.0.260.0040.00417.26
8.0.250.0040.00417.16
8.0.240.0080.00017.05
8.0.230.0030.00417.02
8.0.220.0070.00017.01
8.0.210.0040.00417.04
8.0.200.0000.00717.16
8.0.190.0040.00417.03
8.0.180.0000.00717.05
8.0.170.0000.00717.06
8.0.160.0070.00016.95
8.0.150.0000.00717.01
8.0.140.0030.00617.03
8.0.130.0060.00013.47
8.0.120.0040.00417.06
8.0.110.0030.00617.01
8.0.100.0000.00717.04
8.0.90.0000.00817.04
8.0.80.0060.01217.10
8.0.70.0070.00016.95
8.0.60.0060.00316.96
8.0.50.0000.00717.04
8.0.30.0090.01117.05
8.0.20.0100.00817.40
8.0.10.0030.00616.95
8.0.00.0080.00917.12
7.4.330.0020.00216.90
7.4.320.0000.00716.63
7.4.300.0060.00016.71
7.4.290.0000.00716.57
7.4.280.0050.00316.68
7.4.270.0070.00016.68
7.4.260.0000.00716.64
7.4.250.0000.00816.61
7.4.240.0060.00216.67
7.4.230.0070.00016.66
7.4.220.0060.01116.60
7.4.210.0130.00316.71
7.4.200.0060.00316.85
7.4.160.0160.00016.66
7.4.150.0070.01017.40
7.4.140.0140.00817.86
7.4.130.0110.00816.57
7.4.120.0090.01216.65
7.4.110.0110.00716.50
7.4.100.0120.00916.81
7.4.90.0040.01516.65
7.4.80.0150.00419.39
7.4.70.0180.00016.61
7.4.60.0080.00816.79
7.4.50.0100.00616.65
7.4.40.0160.00816.72
7.4.30.0060.01416.62
7.4.00.0050.01015.28
7.3.330.0030.00313.47
7.3.320.0030.00313.53
7.3.310.0000.00716.46
7.3.300.0030.00316.44
7.3.290.0020.01216.45
7.3.280.0110.00516.46
7.3.270.0070.01117.40
7.3.260.0060.02116.46
7.3.250.0090.01016.68
7.3.240.0150.00516.46
7.3.230.0190.00616.64
7.3.210.0090.00916.48
7.3.200.0070.01016.40
7.3.190.0150.00016.57
7.3.180.0120.00616.52
7.3.170.0110.00816.48
7.3.160.0030.02016.66
7.3.120.0040.01515.09
7.3.110.0090.00914.97
7.3.100.0100.00314.75
7.3.90.0140.00315.23
7.3.80.0070.00715.14
7.3.70.0070.00314.90
7.3.60.0030.00614.75
7.3.50.0030.01314.85
7.3.40.0040.00814.84
7.3.30.0000.01214.91
7.3.20.0100.00716.74
7.3.10.0150.00016.65
7.3.00.0100.00016.38
7.2.330.0110.00716.48
7.2.320.0030.01616.43
7.2.310.0100.00716.77
7.2.300.0080.00916.41
7.2.290.0090.00916.95
7.2.250.0080.01114.92
7.2.240.0030.01714.93
7.2.230.0090.00615.12
7.2.220.0000.01014.82
7.2.210.0070.00715.00
7.2.200.0030.00714.98
7.2.190.0090.00615.13
7.2.180.0070.01015.23
7.2.170.0090.00615.27
7.2.60.0090.00616.93
7.2.00.0000.01119.38
7.1.330.0110.00315.61
7.1.320.0000.01015.68
7.1.310.0060.00615.83
7.1.300.0000.01315.72
7.1.290.0100.00315.59
7.1.280.0060.00615.64
7.1.270.0000.01115.71
7.1.260.0120.00315.48
7.1.200.0040.00815.48
7.1.100.0030.00518.25
7.1.70.0000.00717.28
7.1.60.0030.02219.50
7.1.50.0170.00316.72
7.1.00.0100.06722.44
7.0.200.0050.00516.75
7.0.100.0170.06720.14
7.0.90.0100.08020.02
7.0.80.0030.04319.95
7.0.70.0270.06320.03
7.0.60.0030.07720.08
7.0.50.0030.08720.42
7.0.40.0030.08020.19
7.0.30.0200.06720.06
7.0.20.0130.06020.15
7.0.10.0100.07320.12
7.0.00.0000.09020.10
5.6.280.0030.07320.89
5.6.250.0170.07720.67
5.6.240.0000.09020.69
5.6.230.0130.07320.71
5.6.220.0030.05320.64
5.6.210.0030.09320.70
5.6.200.0030.06321.01
5.6.190.0100.07721.12
5.6.180.0200.07021.00
5.6.170.0130.09321.19
5.6.160.0070.07021.07
5.6.150.0100.07021.19
5.6.140.0030.08321.16
5.6.130.0170.06721.15
5.6.120.0070.07021.09
5.6.110.0000.08721.16
5.6.100.0030.08021.07
5.6.90.0130.08320.96
5.6.80.0070.07020.44
5.6.70.0070.08020.48
5.6.60.0070.07720.53
5.6.50.0030.08720.38
5.6.40.0030.06320.47
5.6.30.0030.07320.55
5.6.20.0200.06720.53
5.6.10.0030.08320.51
5.6.00.0130.06320.51
5.5.380.0070.06720.40
5.5.370.0170.07320.47
5.5.360.0130.05720.53
5.5.350.0100.06320.40
5.5.340.0030.08020.92
5.5.330.0070.07720.87
5.5.320.0070.08720.92
5.5.310.0030.08320.89
5.5.300.0130.05320.89
5.5.290.0100.07320.82
5.5.280.0130.08020.70
5.5.270.0100.08720.82
5.5.260.0070.08320.95
5.5.250.0100.07720.50
5.5.240.0070.06320.43
5.5.230.0100.07720.23
5.5.220.0170.07720.29
5.5.210.0100.08020.20
5.5.200.0100.08020.29
5.5.190.0070.08020.13
5.5.180.0030.09720.27
5.5.160.0100.08020.26
5.5.150.0030.07320.29
5.5.140.0170.07320.30
5.5.130.0070.07320.32
5.5.120.0100.07320.29
5.5.110.0000.08020.20
5.5.100.0130.06720.22
5.5.90.0170.07020.11
5.5.80.0130.06320.02
5.5.70.0030.04020.05
5.5.60.0130.05719.98
5.5.50.0100.04320.15
5.5.40.0130.07020.01
5.5.30.0130.08020.13
5.5.20.0130.07720.11
5.5.10.0030.07720.17
5.5.00.0000.08720.16

preferences:
60.1 ms | 400 KiB | 5 Q