3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?PHP $str = " Monday Tuesday Wednesday Thursday Friday\nSaturday\tSunday"; function a($str) { return str_word_count($str,1,"!\"#$%&'()*+,./0123456789-:;<=>?@[\]^_`{|}~"); }; function c($str) { return preg_split("/\s+/",trim($str)); }; function d($string){ return array_filter(explode(' ', implode(' ', array_map('trim', explode("\n", $string))))); }; function e($str) { $str = trim($str); $words = array(); $len = strlen($str); $word = ''; for ($i = 0; $i < $len; $i++) { $char = $str[$i]; $ord = ord($char); // Is a character if ($ord > 32 && $ord < 127) { $word .= $char; // It's some sort of whitespace } else { if ($word) { $words[] = $word; } $word = ''; } } if ($word) { $words[] = $word; } return $words; }; function f($str,$return_hash = false) { $str = trim($str); // Word characters are any printable char $words = str_word_count($str,1,"!\"#$%&'()*+,./0123456789-:;<=>?@[\]^_`{|}~"); if ($return_hash) { $ret = array(); $num = sizeof($words); // Odd number of elements, can't build a hash if ($num % 2 == 1) { return array(); } else { // Loop over each word and build a key/value hash for ($i = 0; $i < $num; $i += 2) { $key = $words[$i]; $value = $words[$i + 1]; $ret[$key] = $value; } return $ret; } } else { return $words; } }; a($str); c($str); d($str); e($str); f($str);

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).
Note: hhvm uses a JIT which only kicks in after a few runs. Since we run scripts only once, hhvm always runs slower.

VersionSystem time (s)User time (s)Memory (MiB)
7.3.10.0160.00016.88
7.3.00.0000.01216.89
7.2.130.0070.01017.02
7.2.120.0130.00316.91
7.2.110.0080.00617.09
7.2.100.0060.00917.23
7.2.90.0030.01017.18
7.2.80.0000.01017.22
7.2.70.0090.00617.13
7.2.60.0680.01016.28
7.2.50.0590.01216.19
7.2.40.0650.00816.34
7.2.30.1170.00816.31
7.2.20.0970.00816.47
7.2.10.1210.01216.08
7.2.00.0700.01017.45
7.1.250.0070.00715.93
7.1.200.0060.00616.03
7.1.170.1190.01014.02
7.1.160.1910.01216.88
7.1.150.1950.01116.90
7.1.140.1870.01017.12
7.1.130.2290.01416.66
7.1.120.2210.01117.05
7.1.110.2020.01116.19
7.1.100.1030.00917.14
7.1.90.2140.01216.34
7.1.80.2300.01016.17
7.1.70.0680.00716.39
7.1.60.0890.01725.37
7.1.50.1070.01425.18
7.1.40.0850.00925.00
7.1.30.0790.01425.15
7.1.20.0890.01125.01
7.1.10.0690.00715.85
7.1.00.0710.00716.02
7.0.300.1270.00713.72
7.0.290.2340.00916.84
7.0.270.1920.00816.49
7.0.260.2020.00916.94
7.0.250.1950.00716.13
7.0.240.2030.00916.30
7.0.230.2180.00716.08
7.0.220.2030.01016.33
7.0.210.1910.00614.70
7.0.200.0780.01216.06
7.0.190.1010.01116.11
7.0.180.1610.00515.61
7.0.170.0680.00915.69
7.0.160.0800.00915.63
7.0.150.0670.00715.54
7.0.140.0760.00615.51
7.0.130.0680.00815.84
7.0.120.0630.01015.87
7.0.110.0740.00715.94
7.0.100.0780.00915.70
7.0.90.0700.00815.73
7.0.80.0700.00815.71
7.0.70.0660.01015.76
7.0.60.0640.00915.61
7.0.50.0680.01115.70
7.0.40.0790.00415.02
7.0.30.0660.00815.03
7.0.20.0270.00915.01
7.0.10.0400.00915.14
7.0.00.0580.00815.06
hhvm-3.22.00.1340.27991.25
hhvm-3.21.30.1040.21190.45
hhvm-3.21.00.1620.30190.31
hhvm-3.20.20.1420.25190.69
hhvm-3.19.20.1410.26189.77
hhvm-3.18.50.0850.22288.83
hhvm-3.18.40.1340.22888.66
hhvm-3.17.30.0730.15889.20
hhvm-3.15.40.0780.15287.74
hhvm-3.13.20.0870.16698.07
hhvm-3.12.140.0740.16697.76
hhvm-3.11.10.0830.16489.81
hhvm-3.10.10.0820.14886.72
5.6.300.0100.04920.94
5.6.290.0140.05020.87
5.6.280.0120.05920.79
5.6.270.0110.05120.94
5.6.260.0170.05820.92
5.6.250.0150.04820.83
5.6.240.0180.05320.93
5.6.230.0120.05320.93
5.6.220.0130.04720.87
5.6.210.0090.06320.92
5.6.200.0200.05020.83
5.6.190.0140.05820.94
5.6.180.0140.06020.90
5.6.170.0110.05320.88
5.6.160.0110.05220.93
5.6.150.0080.05320.95
5.6.140.0210.05320.85
5.6.130.0120.05120.74
5.6.120.0150.06320.86
5.6.110.0180.05320.91
5.6.100.0110.06720.97
5.6.90.0130.05420.88
5.6.80.0180.05320.23
5.6.70.0150.05220.25
5.6.60.0140.05420.17
5.6.50.0110.05120.32
5.6.40.0150.05320.16
5.6.30.0090.05320.09
5.6.20.0130.05720.20
5.6.10.0150.05920.12
5.6.00.0190.05220.27
5.5.380.0100.04717.55
5.5.370.0090.07217.57
5.5.360.0140.05917.54
5.5.350.0140.05517.64
5.5.340.0150.05618.13
5.5.330.0120.05418.07
5.5.320.0090.04918.01
5.5.310.0090.05518.06
5.5.300.0080.05218.11
5.5.290.0100.06718.07
5.5.280.0130.06317.92
5.5.270.0120.06417.89
5.5.260.0150.05018.05
5.5.250.0140.06017.89
5.5.240.0130.04617.10
5.5.230.0090.05317.49
5.5.220.0160.04817.40
5.5.210.0070.04917.34
5.5.200.0130.04617.31
5.5.190.0070.05617.42
5.5.180.0090.05217.28
5.5.160.0140.05317.39
5.5.150.0120.05017.39
5.5.140.0140.05117.39
5.5.130.0120.06017.24
5.5.120.0070.05317.21
5.5.110.0150.05617.42
5.5.100.0150.04817.31
5.5.90.0160.04917.19
5.5.80.0050.06717.14
5.5.70.0120.04617.35
5.5.60.0100.04717.36
5.5.50.0090.05017.30
5.5.40.0070.05417.36
5.5.30.0120.05017.18
5.5.20.0110.05117.15
5.5.10.0120.04817.20
5.5.00.0090.05217.30
5.4.450.0150.05219.38
5.4.440.0110.06019.33
5.4.430.0130.06119.36
5.4.420.0120.05319.31
5.4.410.0120.05619.27
5.4.400.0150.06319.05
5.4.390.0130.04919.10
5.4.380.0130.04618.91
5.4.370.0130.04519.12
5.4.360.0110.04619.20
5.4.350.0120.04919.08
5.4.340.0110.05219.05
5.4.320.0130.05519.14
5.4.310.0130.04519.09
5.4.300.0120.04718.96
5.4.290.0110.05319.08
5.4.280.0180.04719.01
5.4.270.0130.05019.19
5.4.260.0150.04219.09
5.4.250.0130.05219.08
5.4.240.0130.04519.18
5.4.230.0090.05119.11
5.4.220.0150.04718.95
5.4.210.0080.05519.04
5.4.200.0150.05618.94
5.4.190.0130.04719.01
5.4.180.0100.04318.98
5.4.170.0090.04819.06
5.4.160.0110.04319.04
5.4.150.0190.04718.97
5.4.140.0110.04916.65
5.4.130.0100.04616.70
5.4.120.0110.04316.76
5.4.110.0100.05716.74
5.4.100.0110.04416.69
5.4.90.0070.04616.57
5.4.80.0070.04916.68
5.4.70.0120.03716.61
5.4.60.0120.05416.51
5.4.50.0110.04516.63
5.4.40.0090.04516.47
5.4.30.0130.04316.60
5.4.20.0100.04816.64
5.4.10.0100.05216.54
5.4.00.0060.04416.09
5.3.290.0160.04715.10
5.3.280.0160.04615.04
5.3.270.0080.04814.86
5.3.260.0080.05815.01
5.3.250.0090.05114.94
5.3.240.0100.05214.94
5.3.230.0130.04714.91
5.3.220.0110.05214.93
5.3.210.0080.05814.93
5.3.200.0160.03815.04
5.3.190.0090.04614.89
5.3.180.0090.04915.04
5.3.170.0080.05814.93
5.3.160.0100.04414.99
5.3.150.0110.04715.00
5.3.140.0080.04815.03
5.3.130.0100.05814.88
5.3.120.0080.04815.03
5.3.110.0080.04514.92
5.3.100.0080.05314.78
5.3.90.0090.04514.71
5.3.80.0150.03814.73
5.3.70.0110.04514.68
5.3.60.0100.04314.72
5.3.50.0080.04414.68
5.3.40.0070.06014.68
5.3.30.0060.05114.68
5.3.20.0080.04514.40
5.3.10.0120.04514.58
5.3.00.0090.05014.56
5.2.170.0060.04213.34
5.2.160.0100.03913.34
5.2.150.0090.03813.34
5.2.140.0090.05113.29
5.2.130.0090.03413.31
5.2.120.0070.04013.19
5.2.110.0110.02913.19
5.2.100.0050.03613.27
5.2.90.0120.04013.27
5.2.80.0060.03913.19
5.2.70.0090.03513.25
5.2.60.0080.03713.14
5.2.50.0090.03513.22
5.2.40.0130.04113.27
5.2.30.0050.04113.19
5.2.20.0080.03513.24
5.2.10.0120.03913.18
5.2.00.0110.04913.07
5.1.60.0090.04012.78
5.1.50.0070.04012.71
5.1.40.0070.03012.75
5.1.30.0070.03212.89
5.1.20.0070.03812.91
5.1.10.0060.03212.68
5.1.00.0080.05112.75
5.0.50.0050.02912.25
5.0.40.0050.02412.25
5.0.30.0060.03812.25
5.0.20.0050.02412.25
5.0.10.0060.03012.25
5.0.00.0050.05312.25
4.4.90.0050.02412.25
4.4.80.0060.01712.25
4.4.70.0050.02312.25
4.4.60.0040.02012.25
4.4.50.0040.01812.25
4.4.40.0020.03812.25
4.4.30.0090.01812.25
4.4.20.0060.01812.25
4.4.10.0050.02612.25
4.4.00.0070.03012.25
4.3.110.0030.02412.25
4.3.100.0050.01812.25
4.3.90.0060.01812.25
4.3.80.0050.03412.25
4.3.70.0030.02312.25
4.3.60.0100.01812.25
4.3.50.0050.02112.25
4.3.40.0050.03312.25
4.3.30.0040.01912.25
4.3.20.0020.02212.25
4.3.10.0050.01912.25
4.3.00.0040.02112.25