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; } $start2 = runTest2(); $start1 = runTest1(); 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 26.01% faster than Test2
Output for 7.0.14
Test1 is 34.16% faster than Test2
Output for 7.0.6
Test1 is 16.05% faster than Test2
Output for 7.0.5
Test1 is 23.12% faster than Test2
Output for 7.0.4
Test1 is 22.89% faster than Test2
Output for 7.0.3
Test1 is 23.84% faster than Test2
Output for 7.0.2
Test1 is 24% faster than Test2
Output for 7.0.1
Test1 is 22.78% faster than Test2
Output for 7.0.0
Test1 is 20.96% faster than Test2
Output for hhvm-3.12.0
Test2 is 4.45% faster than Test1
Output for hhvm-3.10.0
Test2 is 6.76% faster than Test1
Output for 5.6.21
Test1 is 9.8% faster than Test2
Output for 5.6.20
Test1 is 10.5% faster than Test2
Output for 5.6.19
Test1 is 23.11% faster than Test2
Output for 5.6.18
Test1 is 11.26% faster than Test2
Output for 5.6.17
Test2 is 3.08% faster than Test1
Output for 5.6.16
Test1 is 13.04% faster than Test2
Output for 5.6.15
Test1 is 9% faster than Test2
Output for 5.6.14
Test1 is 13.39% faster than Test2
Output for 5.6.13
Test1 is 13.81% faster than Test2
Output for 5.6.12
Test1 is 8.38% faster than Test2
Output for 5.6.11
Test1 is 10.75% faster than Test2
Output for 5.6.10
Test1 is 18.25% faster than Test2
Output for 5.6.9
Test1 is 10.89% faster than Test2
Output for 5.6.8
Test1 is 6.9% faster than Test2
Output for 5.6.7
Test1 is 11.49% faster than Test2
Output for 5.5.35
Test1 is 9.89% faster than Test2
Output for 5.5.34
Test1 is 8.08% faster than Test2
Output for 5.5.33
Test1 is 5.99% faster than Test2
Output for 5.5.32
Test1 is 5.96% faster than Test2
Output for 5.5.31
Test1 is 6.89% faster than Test2
Output for 5.5.30
Test1 is 4.52% faster than Test2
Output for 5.5.29
Test1 is 8.23% faster than Test2
Output for 5.5.28
Test1 is 7.84% faster than Test2
Output for 5.5.27
Test1 is 10.55% faster than Test2
Output for 5.5.26
Test1 is 1.67% faster than Test2
Output for 5.5.25
Test1 is 8.09% faster than Test2
Output for 5.5.24
Test1 is 10.2% faster than Test2
Output for 5.4.45
Test1 is 7.2% faster than Test2
Output for 5.4.44
Test1 is 5.25% faster than Test2
Output for 5.4.43
Test1 is 7.04% faster than Test2
Output for 5.4.42
Test1 is 7.33% faster than Test2
Output for 5.4.41
Test1 is 5.53% faster than Test2
Output for 5.3.25, 5.4.40
Test1 is 3.6% faster than Test2
Output for 5.4.39
Test1 is 8.36% faster than Test2
Output for 5.4.38
Test1 is 9.24% faster than Test2
Output for 5.4.37
Test1 is 5.84% faster than Test2
Output for 5.4.36
Test1 is 5.56% faster than Test2
Output for 5.4.35
Test1 is 8.91% faster than Test2
Output for 5.1.0, 5.4.34
Test1 is 8.07% faster than Test2
Output for 5.4.32
Test2 is 0.93000000000001% faster than Test1
Output for 5.4.31
Test1 is 11.58% faster than Test2
Output for 5.4.30
Test1 is 5.18% faster than Test2
Output for 5.4.29
Test1 is 7.29% faster than Test2
Output for 5.4.28
Test1 is 6.78% faster than Test2
Output for 5.4.27
Test2 is 1.11% faster than Test1
Output for 5.4.26
Test1 is 3.02% faster than Test2
Output for 5.4.25
Test1 is 6.24% faster than Test2
Output for 5.4.24
Test1 is 9.97% faster than Test2
Output for 5.4.23
Test1 is 3.81% faster than Test2
Output for 5.4.7, 5.4.22
Test1 is 2.56% faster than Test2
Output for 5.4.21
Test1 is 6.35% faster than Test2
Output for 5.4.20
Test1 is 6.81% faster than Test2
Output for 5.4.19
Test1 is 11.16% faster than Test2
Output for 5.4.18
Test1 is 8.65% faster than Test2
Output for 5.4.17
Test1 is 14.22% faster than Test2
Output for 4.4.6, 5.4.16
Test1 is 4.34% faster than Test2
Output for 5.4.15
Test1 is 11.17% faster than Test2
Output for 5.4.14
Test1 is 1.11% faster than Test2
Output for 5.4.13
Test1 is 5.29% faster than Test2
Output for 5.4.12
Test1 is 6.21% faster than Test2
Output for 5.4.11
Test1 is 6.52% faster than Test2
Output for 5.1.3, 5.4.10
Test1 is 5.92% faster than Test2
Output for 4.3.1, 5.4.9
Test1 is 0.12% faster than Test2
Output for 5.4.8
Test1 is 2.21% faster than Test2
Output for 5.4.6
Test1 is 5.42% faster than Test2
Output for 5.4.5
Test1 is 5.88% faster than Test2
Output for 5.4.4
Test1 is 5.86% faster than Test2
Output for 4.3.3, 5.4.3
Test1 is 7.24% faster than Test2
Output for 5.4.2
Test1 is 6.25% faster than Test2
Output for 5.4.1
Test1 is 7.23% faster than Test2
Output for 5.4.0
Test1 is 11.45% faster than Test2
Output for 5.3.29
Test1 is 14.38% faster than Test2
Output for 5.3.28
Test1 is 3.86% faster than Test2
Output for 5.3.27
Test1 is 1.86% faster than Test2
Output for 5.3.26
Test1 is 3.1% faster than Test2
Output for 5.3.24
Test1 is 3.04% faster than Test2
Output for 5.3.23
Test2 is 2.14% faster than Test1
Output for 5.3.22
Test1 is 4.48% faster than Test2
Output for 5.3.21
Test1 is 2.33% faster than Test2
Output for 5.3.20
Test1 is 3.9% faster than Test2
Output for 5.3.19
Test1 is 4.5% faster than Test2
Output for 5.3.18
Test1 is 4.4% faster than Test2
Output for 5.3.17
Test1 is 0.45999999999999% faster than Test2
Output for 5.3.16
Test1 is 3.98% faster than Test2
Output for 5.3.15
Test1 is 4.39% faster than Test2
Output for 5.3.14
Test1 is 5.49% faster than Test2
Output for 5.3.13
Test1 is 5.3% faster than Test2
Output for 5.3.12
Test1 is 3.67% faster than Test2
Output for 5.3.11
Test1 is 3.48% faster than Test2
Output for 5.3.10
Test1 is 8.95% faster than Test2
Output for 5.3.9
Test1 is 2.84% faster than Test2
Output for 5.3.8
Test1 is 7.6% faster than Test2
Output for 5.3.7
Test1 is 6.05% faster than Test2
Output for 5.3.6
Test1 is 4.42% faster than Test2
Output for 5.3.5
Test1 is 2.66% faster than Test2
Output for 5.3.4
Test2 is 11.3% faster than Test1
Output for 5.3.3
Test1 is 14.55% faster than Test2
Output for 5.3.2
Test1 is 9.37% faster than Test2
Output for 5.3.1
Test1 is 4.01% faster than Test2
Output for 5.3.0
Test1 is 4.77% faster than Test2
Output for 5.2.17
Test1 is 11.55% faster than Test2
Output for 5.2.16
Test1 is 9.7% faster than Test2
Output for 5.2.15
Test1 is 9.47% faster than Test2
Output for 5.2.6, 5.2.14
Test1 is 6.91% faster than Test2
Output for 5.2.13
Test1 is 7.17% faster than Test2
Output for 5.2.12
Test1 is 11.19% faster than Test2
Output for 5.2.11
Test1 is 10.58% faster than Test2
Output for 5.2.10
Test1 is 9.2% faster than Test2
Output for 5.2.9
Test1 is 6.8% faster than Test2
Output for 5.2.8
Test2 is 20.61% faster than Test1
Output for 5.2.7
Test1 is 14.51% faster than Test2
Output for 5.2.5
Test1 is 10.72% faster than Test2
Output for 5.2.4
Test2 is 7.55% faster than Test1
Output for 5.2.3
Test1 is 7.53% faster than Test2
Output for 5.2.2
Test1 is 6.88% faster than Test2
Output for 5.2.1
Test1 is 0.48999999999999% faster than Test2
Output for 5.2.0
Test1 is 8.78% faster than Test2
Output for 5.1.6
Test1 is 6.34% faster than Test2
Output for 5.1.5
Test1 is 6.83% faster than Test2
Output for 5.1.4
Test1 is 6.3% faster than Test2
Output for 5.1.2
Test1 is 6.84% faster than Test2
Output for 5.1.1
Test1 is 7.01% faster than Test2
Output for 5.0.5
Test1 is 2.54% faster than Test2
Output for 5.0.4
Test2 is 2.39% faster than Test1
Output for 5.0.3
Test1 is 0.34999999999999% faster than Test2
Output for 5.0.2
Test1 is 5.15% faster than Test2
Output for 5.0.1
Test1 is 4.53% faster than Test2
Output for 5.0.0
Test1 is 1.04% faster than Test2
Output for 4.4.9
Test2 is 9.84% faster than Test1
Output for 4.4.8
Test1 is 3.11% faster than Test2
Output for 4.4.7
Test2 is 0.58% faster than Test1
Output for 4.4.5
Test1 is 8.37% faster than Test2
Output for 4.4.4
Test1 is 6.95% faster than Test2
Output for 4.4.3
Test1 is 5.98% faster than Test2
Output for 4.4.2
Test1 is 7.86% faster than Test2
Output for 4.4.1
Test2 is 9.29% faster than Test1
Output for 4.4.0
Test1 is 24.54% faster than Test2
Output for 4.3.11
Test1 is 9.73% faster than Test2
Output for 4.3.10
Test2 is 0.40000000000001% faster than Test1
Output for 4.3.9
Test1 is 2.87% faster than Test2
Output for 4.3.8
Test1 is 3.84% faster than Test2
Output for 4.3.7
Test1 is 4.46% faster than Test2
Output for 4.3.6
Test2 is 16.4% faster than Test1
Output for 4.3.5
Test1 is 4.82% faster than Test2
Output for 4.3.4
Test1 is 5.67% faster than Test2
Output for 4.3.2
Test1 is 2.88% faster than Test2
Output for 4.3.0
Test1 is 1.98% faster than Test2