3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function test1() { $str = 'derp'; if ($str != 'files' && $str != 'something' && $str != 'Derrr') { return; } return; } function test2() { $str = 'derp'; switch ($str) { case 'files': case 'something': case 'Derrr': break; default: return; } return; } function runTest1() { $start1 = microtime(1); for ($i = 1; $i < 10000; $i++) { test1(); } $start1 -= microtime(1); return $start1; } function runTest2() { $start2 = microtime(1); for ($i = 1; $i < 10000; $i++) { test2(); } $start2 -= microtime(1); return $start2; } $tests = 10; $tests2 = 0; for($i = 0;$i<$tests;$i++) { $tests2 += runTest2(); } $start2 = $tests2 / $tests; $tests1 = 0; for($i = 0;$i<$tests;$i++) { $tests1 += runTest1(); } $start1 = $tests1 / $tests; if ($start1 < $start2) { $perc = 100-round(($start2 / $start1) * 100,2); echo "Test1 is $perc"."% faster than Test2"; } if ($start2 < $start1) { $perc = 100-round(($start1 / $start2) * 100,2); echo "Test2 is $perc"."% faster than Test1"; }
Output for 7.1.0
Test1 is 30.29% faster than Test2
Output for 7.0.14
Test1 is 28.54% faster than Test2
Output for 7.0.12
Test1 is 25.47% faster than Test2
Output for 7.0.6
Test1 is 15.86% faster than Test2
Output for 7.0.5
Test1 is 21.64% faster than Test2
Output for 7.0.4
Test1 is 22.39% faster than Test2
Output for 7.0.3
Test1 is 28.74% faster than Test2
Output for 7.0.2
Test1 is 24.57% faster than Test2
Output for 7.0.1
Test1 is 20.21% faster than Test2
Output for 7.0.0
Test1 is 31.91% faster than Test2
Output for 5.6.28
Test1 is 0.44% faster than Test2
Output for 5.6.21
Test1 is 9.03% faster than Test2
Output for 5.6.20
Test2 is 2.29% faster than Test1
Output for 5.6.19
Test1 is 10.02% faster than Test2
Output for 5.6.18
Test1 is 4.5% faster than Test2
Output for 5.6.17
Test1 is 9.15% faster than Test2
Output for 5.6.16
Test1 is 1.51% faster than Test2
Output for 5.6.15
Test1 is 10.67% faster than Test2
Output for 5.6.14
Test1 is 3.38% faster than Test2
Output for 5.6.13
Test1 is 3.16% faster than Test2
Output for 5.6.12
Test1 is 5.04% faster than Test2
Output for 5.6.11
Test2 is 7.19% faster than Test1
Output for 5.6.10
Test1 is 9.92% faster than Test2
Output for 5.5.33, 5.6.9
Test1 is 4.63% faster than Test2
Output for 5.6.8
Test1 is 0.29000000000001% faster than Test2
Output for 5.5.35
Test1 is 2.75% faster than Test2
Output for 5.5.34
Test1 is 23.31% faster than Test2
Output for 5.5.32
Test1 is 10.24% faster than Test2
Output for 5.5.31
Test1 is 2.85% faster than Test2
Output for 5.5.30
Test2 is 1.01% faster than Test1
Output for 5.5.29
Test1 is 8.07% faster than Test2
Output for 5.5.28
Test2 is 25.29% faster than Test1
Output for 5.5.27
Test1 is 16.2% faster than Test2
Output for 5.5.26
Test1 is 8.67% faster than Test2
Output for 5.5.25
Test1 is 7.57% faster than Test2
Output for 5.5.24
Test1 is 7.58% faster than Test2
Output for 5.4.10, 5.4.45
Test2 is 3.72% faster than Test1
Output for 5.4.44
Test2 is 3.42% faster than Test1
Output for 5.2.3, 5.4.43
Test2 is 6.7% faster than Test1
Output for 5.4.42
Test1 is 7.68% faster than Test2
Output for 5.4.41
Test2 is 9.48% faster than Test1
Output for 5.4.40
Test2 is 3.14% faster than Test1
Output for 5.4.39
Test2 is 4.19% faster than Test1
Output for 5.4.38
Test2 is 1.81% faster than Test1
Output for 5.4.37
Test2 is 13.25% faster than Test1
Output for 5.4.36
Test2 is 1.28% faster than Test1
Output for 5.4.35
Test1 is 34.55% faster than Test2
Output for 5.4.34
Test1 is 4.96% faster than Test2
Output for 5.4.32
Test2 is 4.24% faster than Test1
Output for 5.4.31
Test2 is 6.65% faster than Test1
Output for 5.4.4, 5.4.30
Test1 is 4.98% faster than Test2
Output for 5.4.29
Test1 is 1.1% faster than Test2
Output for 5.4.28
Test2 is 1.11% faster than Test1
Output for 5.4.27
Test2 is 6.97% faster than Test1
Output for 5.4.26
Test1 is 10.3% faster than Test2
Output for 5.4.25
Test2 is 17.02% faster than Test1
Output for 5.4.24
Test1 is 2.91% faster than Test2
Output for 5.4.23
Test1 is 4.93% faster than Test2
Output for 5.4.22
Test2 is 2.41% faster than Test1
Output for 5.4.21
Test2 is 7.82% faster than Test1
Output for 5.4.20
Test1 is 4.03% faster than Test2
Output for 5.4.19
Test2 is 1.08% faster than Test1
Output for 5.4.18
Test1 is 3.2% faster than Test2
Output for 5.4.17
Test1 is 8.94% faster than Test2
Output for 5.4.16
Test2 is 6.2% faster than Test1
Output for 5.4.15
Test1 is 5.44% faster than Test2
Output for 5.4.14
Test2 is 20.22% faster than Test1
Output for 5.4.13
Test2 is 6.07% faster than Test1
Output for 5.4.12
Test2 is 1.66% faster than Test1
Output for 5.4.11
Test1 is 6.29% faster than Test2
Output for 5.4.9
Test2 is 0.88% faster than Test1
Output for 5.4.8
Test2 is 7.14% faster than Test1
Output for 5.4.7
Test1 is 1.96% faster than Test2
Output for 5.4.6
Test2 is 2.85% faster than Test1
Output for 5.4.5
Test1 is 2.96% faster than Test2
Output for 5.4.3
Test1 is 6.05% faster than Test2
Output for 5.4.2
Test1 is 7.97% faster than Test2
Output for 5.4.1
Test1 is 6.95% faster than Test2
Output for 5.4.0
Test1 is 9.8% faster than Test2
Output for 5.3.29
Test1 is 1.98% faster than Test2
Output for 5.3.28
Test2 is 7.34% faster than Test1
Output for 5.3.27
Test2 is 5.66% faster than Test1
Output for 5.3.26
Test2 is 24.39% faster than Test1
Output for 5.3.25
Test2 is 5.33% faster than Test1
Output for 5.3.24
Test2 is 13.56% faster than Test1
Output for 5.3.23
Test2 is 8.3% faster than Test1
Output for 5.3.22
Test2 is 8.09% faster than Test1
Output for 5.3.21
Test2 is 21.26% faster than Test1
Output for 5.3.20
Test1 is 0.040000000000006% faster than Test2
Output for 5.3.19
Test2 is 6.55% faster than Test1
Output for 5.3.18
Test1 is 3.55% faster than Test2
Output for 5.3.17
Test2 is 8.54% faster than Test1
Output for 5.3.16
Test2 is 5.77% faster than Test1
Output for 5.3.15
Test2 is 11.78% faster than Test1
Output for 5.3.14
Test1 is 4.68% faster than Test2
Output for 5.3.13
Test1 is 14.2% faster than Test2
Output for 5.3.12
Test1 is 5.77% faster than Test2
Output for 5.3.11
Test1 is 4.19% faster than Test2
Output for 5.3.10
Test1 is 9.06% faster than Test2
Output for 5.3.9
Test1 is 5.3% faster than Test2
Output for 5.3.8
Test1 is 6.14% faster than Test2
Output for 5.3.7
Test1 is 6.02% faster than Test2
Output for 5.3.6
Test1 is 4.14% faster than Test2
Output for 5.3.5
Test2 is 1.74% faster than Test1
Output for 5.3.4
Test1 is 6.96% faster than Test2
Output for 5.3.3
Test1 is 6.46% faster than Test2
Output for 5.3.2
Test1 is 11.83% faster than Test2
Output for 5.3.1
Test1 is 6.4% faster than Test2
Output for 5.3.0
Test1 is 5.47% faster than Test2
Output for 5.2.17
Test1 is 11.64% faster than Test2
Output for 5.2.16
Test1 is 9.34% faster than Test2
Output for 5.2.15
Test1 is 11.08% faster than Test2
Output for 5.2.14
Test1 is 10.75% faster than Test2
Output for 5.2.13
Test1 is 10.1% faster than Test2
Output for 5.2.12
Test1 is 11.88% faster than Test2
Output for 5.2.11
Test1 is 10.65% faster than Test2
Output for 5.2.10
Test1 is 10.88% faster than Test2
Output for 5.2.9
Test1 is 9.13% faster than Test2
Output for 5.2.8
Test1 is 6.2% faster than Test2
Output for 5.2.7
Test1 is 10.95% faster than Test2
Output for 5.2.6
Test1 is 8.63% faster than Test2
Output for 5.2.5
Test2 is 1.07% faster than Test1
Output for 5.2.4
Test1 is 0.17% faster than Test2
Output for 5.2.2
Test1 is 11.93% faster than Test2
Output for 5.2.1
Test2 is 1.56% faster than Test1
Output for 5.2.0
Test1 is 3.74% faster than Test2
Output for 5.1.6
Test2 is 2.26% faster than Test1
Output for 5.1.5
Test1 is 9.37% faster than Test2
Output for 5.1.4
Test1 is 8.17% faster than Test2
Output for 5.1.3
Test1 is 0.38% faster than Test2
Output for 5.1.2
Test1 is 11.28% faster than Test2
Output for 5.1.1
Test2 is 10.46% faster than Test1
Output for 5.1.0
Test1 is 14.19% faster than Test2
Output for 5.0.5
Test2 is 17.72% faster than Test1
Output for 5.0.4
Test2 is 16.33% faster than Test1
Output for 5.0.3
Test2 is 6.44% faster than Test1
Output for 5.0.2
Test2 is 15.99% faster than Test1
Output for 5.0.1
Test1 is 7.63% faster than Test2
Output for 5.0.0
Test2 is 3.65% faster than Test1
Output for 4.4.9
Test1 is 10.91% faster than Test2
Output for 4.4.8
Test1 is 7.96% faster than Test2
Output for 4.4.7
Test2 is 19.88% faster than Test1
Output for 4.4.6
Test1 is 1753.05% faster than Test2
Output for 4.4.5
Test2 is 17.98% faster than Test1
Output for 4.4.4
Test2 is 3.67% faster than Test1
Output for 4.4.3
Test1 is 10.55% faster than Test2
Output for 4.4.2
Test1 is 10.09% faster than Test2
Output for 4.4.1
Test2 is 17.74% faster than Test1
Output for 4.4.0
Test2 is 8.88% faster than Test1
Output for 4.3.11
Test2 is 28.3% faster than Test1
Output for 4.3.10
Test1 is 5.95% faster than Test2
Output for 4.3.9
Test2 is 15.52% faster than Test1
Output for 4.3.8
Test2 is 16.76% faster than Test1
Output for 4.3.7
Test2 is 12.78% faster than Test1
Output for 4.3.6
Test2 is 29.81% faster than Test1
Output for 4.3.5
Test2 is 1463.64% faster than Test1
Output for 4.3.4
Test2 is 16.82% faster than Test1
Output for 4.3.3
Test1 is 7.53% faster than Test2
Output for 4.3.2
Test2 is 30.38% faster than Test1
Output for 4.3.1
Test1 is 1757.56% faster than Test2
Output for 4.3.0
Test2 is 25.88% faster than Test1