3v4l.org

run code in 300+ PHP versions simultaneously
<?php function lzw_encode(s) { var dict = {}; var data = (s + "").split(""); var out = []; var currChar; var phrase = data[0]; var code = 256; for (var i=1; i<data.length; i++) { currChar=data[i]; if (dict[phrase + currChar] != null) { phrase += currChar; } else { out.push(phrase.length > 1 ? dict[phrase] : phrase.charCodeAt(0)); dict[phrase + currChar] = code; code++; phrase=currChar; } } out.push(phrase.length > 1 ? dict[phrase] : phrase.charCodeAt(0)); for (var i=0; i<out.length; i++) { out[i] = String.fromCharCode(out[i]); } return out.join(""); } // Decompress an LZW-encoded string function lzw_decode(s) { var dict = {}; var data = (s + "").split(""); var currChar = data[0]; var oldPhrase = currChar; var out = [currChar]; var code = 256; var phrase; for (var i=1; i<data.length; i++) { var currCode = data[i].charCodeAt(0); if (currCode < 256) { phrase = data[i]; } else { phrase = dict[currCode] ? dict[currCode] : (oldPhrase + currChar); } out.push(phrase); currChar = phrase.charAt(0); dict[code] = oldPhrase + currChar; code++; oldPhrase = phrase; } return out.join(""); } echo lzw_encode('');

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)
5.4.270.0100.07718.95
5.4.260.0130.07318.84
5.4.250.0200.06018.99
5.4.240.0100.07318.76
5.4.230.0070.05718.98
5.4.220.0100.05718.64
5.4.210.0230.06018.94
5.4.200.0130.05318.79
5.4.190.0170.06718.83
5.4.180.0000.05718.93
5.4.170.0170.05018.96
5.4.160.0100.07019.00
5.4.150.0130.07718.94
5.4.140.0200.06016.33
5.4.130.0070.04716.38
5.4.120.0070.07316.42
5.4.110.0070.05016.62
5.4.100.0030.05716.49
5.4.90.0070.04716.65
5.4.80.0170.04016.39
5.4.70.0100.07016.49
5.4.60.0230.04016.39
5.4.50.0030.05316.36
5.4.40.0100.07016.59
5.4.30.0100.07016.52
5.4.20.0030.07316.37
5.4.10.0200.05016.43
5.4.00.0130.06316.01
5.3.280.0200.06014.81
5.3.270.0200.05014.76
5.3.260.0100.07714.62
5.3.250.0000.06314.62
5.3.240.0170.04314.79
5.3.230.0130.05014.62
5.3.220.0130.05714.54
5.3.210.0130.04714.65
5.3.200.0030.07014.58
5.3.190.0270.06714.65
5.3.180.0100.05014.53
5.3.170.0130.04714.55
5.3.160.0100.05314.64
5.3.150.0170.06714.64
5.3.140.0030.05314.57
5.3.130.0070.05314.73
5.3.120.0100.05014.63
5.3.110.0200.04314.72
5.3.100.0030.07313.94
5.3.90.0270.05714.00
5.3.80.0030.07014.19
5.3.70.0100.07714.00
5.3.60.0270.05314.00
5.3.50.0270.05014.12
5.3.40.0100.06314.16
5.3.30.0130.06313.91
5.3.20.0200.05313.69
5.3.10.0070.04713.55
5.3.00.0170.06013.74
5.2.170.0070.05711.21
5.2.160.0100.04011.31
5.2.150.0070.04711.09
5.2.140.0100.04011.21
5.2.130.0030.06011.27
5.2.120.0030.04711.31
5.2.110.0200.03710.92
5.2.100.0130.04011.17
5.2.90.0070.05711.18
5.2.80.0100.04711.17
5.2.70.0100.05311.06
5.2.60.0130.05311.21
5.2.50.0130.04710.92
5.2.40.0070.04011.21
5.2.30.0070.04010.93
5.2.20.0130.03710.95
5.2.10.0070.03710.95
5.2.00.0100.05310.71
5.1.60.0070.03010.03
5.1.50.0130.03010.00
5.1.40.0030.0379.93
5.1.30.0070.04710.41
5.1.20.0130.05010.34
5.1.10.0100.04010.04
5.1.00.0030.03710.07
5.0.50.0000.0378.54
5.0.40.0070.0238.60
5.0.30.0070.0408.22
5.0.20.0000.0338.39
5.0.10.0100.0308.40
5.0.00.0130.0478.39
4.4.90.0070.0207.21
4.4.80.0000.0277.21
4.4.70.0030.0237.21
4.4.60.0070.0177.21
4.4.50.0000.0237.21
4.4.40.0030.0337.21
4.4.30.0000.0307.21
4.4.20.0100.0137.21
4.4.10.0030.0207.21
4.4.00.0070.0407.21
4.3.110.0170.0107.21
4.3.100.0030.0237.21
4.3.90.0000.0237.21
4.3.80.0030.0337.21
4.3.70.0070.0237.21
4.3.60.0030.0207.21
4.3.50.0070.0177.21
4.3.40.0070.0377.21
4.3.30.0030.0307.21
4.3.20.0130.0107.21
4.3.10.0030.0237.21
4.3.00.0030.0276.98

preferences:
141.64 ms | 1394 KiB | 7 Q