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 = 100; $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 7.12% faster than Test2
Output for 7.0.14
Test1 is 10.63% faster than Test2
Output for 7.0.9
Test1 is 14.93% faster than Test2
Output for 7.0.8
Test1 is 20.62% faster than Test2
Output for 7.0.7
Test1 is 23.02% faster than Test2
Output for 7.0.6
Test1 is 20.38% faster than Test2
Output for 7.0.5
Test1 is 24.79% faster than Test2
Output for 7.0.4
Test1 is 0.40000000000001% faster than Test2
Output for 7.0.3
Test1 is 17.06% faster than Test2
Output for 7.0.2
Test2 is 3.07% faster than Test1
Output for 7.0.1
Test1 is 12.65% faster than Test2
Output for 7.0.0
Test1 is 11.64% faster than Test2
Output for hhvm-3.12.0
Test2 is 3.4% faster than Test1
Output for hhvm-3.10.0
Test2 is 2.55% faster than Test1
Output for 5.6.28
Test2 is 199.77% faster than Test1
Output for 5.6.23
Test2 is 7.55% faster than Test1
Output for 5.6.22
Test1 is 3.68% faster than Test2
Output for 5.6.21
Test1 is 4.95% faster than Test2
Output for 5.6.20
Test1 is 10.52% faster than Test2
Output for 5.6.19
Test2 is 3.87% faster than Test1
Output for 5.6.18
Test1 is 8.66% faster than Test2
Output for 5.6.17
Test1 is 3.61% faster than Test2
Output for 5.6.16
Test2 is 4.64% faster than Test1
Output for 5.6.15
Test1 is 8.71% faster than Test2
Output for 5.6.14
Test1 is 3.74% faster than Test2
Output for 5.2.12, 5.6.13
Test1 is 1.51% faster than Test2
Output for 5.6.12
Test1 is 2.42% faster than Test2
Output for 5.6.11
Test1 is 12.94% faster than Test2
Output for 5.6.10
Test1 is 1.99% faster than Test2
Output for 5.6.9
Test1 is 6.6% faster than Test2
Output for 5.6.8
Test2 is 5.4% faster than Test1
Output for 5.6.7
Test2 is 11.36% faster than Test1
Output for 5.6.6
Test1 is 8.92% faster than Test2
Output for 5.6.5
Test1 is 8.37% faster than Test2
Output for 5.6.4
Test1 is 13.2% faster than Test2
Output for 5.6.3
Test2 is 1.36% faster than Test1
Output for 5.6.2
Test2 is 9.98% faster than Test1
Output for 5.6.1
Test1 is 9.91% faster than Test2
Output for 5.6.0
Test2 is 6.38% faster than Test1
Output for 5.5.37
Test1 is 3.11% faster than Test2
Output for 5.5.36
Test2 is 13.52% faster than Test1
Output for 5.5.35
Test1 is 12.91% faster than Test2
Output for 5.5.34
Test1 is 3.63% faster than Test2
Output for 5.5.33
Test1 is 8.21% faster than Test2
Output for 5.5.32
Test2 is 22.62% faster than Test1
Output for 5.5.31
Test2 is 9.14% faster than Test1
Output for 5.5.30
Test1 is 6.21% faster than Test2
Output for 5.5.29
Test1 is 10.09% faster than Test2
Output for 5.5.28
Test1 is 5.05% faster than Test2
Output for 5.5.27
Test1 is 8.26% faster than Test2
Output for 5.5.26
Test1 is 4.27% faster than Test2
Output for 5.5.25
Test1 is 3.76% faster than Test2
Output for 5.5.24
Test2 is 5.73% faster than Test1
Output for 5.5.23
Test1 is 7.58% faster than Test2
Output for 5.5.22
Test1 is 9.66% faster than Test2
Output for 5.5.21
Test2 is 1.99% faster than Test1
Output for 5.5.20
Test1 is 5.29% faster than Test2
Output for 5.5.19
Test1 is 2.51% faster than Test2
Output for 5.5.18
Test1 is 1.14% faster than Test2
Output for 5.5.16
Test1 is 8.44% faster than Test2
Output for 5.5.15
Test1 is 1.31% faster than Test2
Output for 5.5.14
Test1 is 3.13% faster than Test2
Output for 5.5.13
Test2 is 5.35% faster than Test1
Output for 5.5.12
Test2 is 8.21% faster than Test1
Output for 5.5.11
Test1 is 1.37% faster than Test2
Output for 5.5.10
Test2 is 7.66% faster than Test1
Output for 5.5.9
Test1 is 7.82% faster than Test2
Output for 5.5.8
Test1 is 3.17% faster than Test2
Output for 5.5.7
Test2 is 1.4% faster than Test1
Output for 5.5.6
Test2 is 8.12% faster than Test1
Output for 5.5.5
Test1 is 2.61% faster than Test2
Output for 5.5.4
Test1 is 8.29% faster than Test2
Output for 5.5.3
Test1 is 3.5% faster than Test2
Output for 5.5.2
Test2 is 2.44% faster than Test1
Output for 5.5.1
Test2 is 9.89% faster than Test1
Output for 5.3.24, 5.5.0
Test2 is 9.84% faster than Test1
Output for 5.4.45
Test2 is 13.9% faster than Test1
Output for 5.4.44
Test1 is 4.66% faster than Test2
Output for 5.4.43
Test1 is 4.43% faster than Test2
Output for 5.4.42
Test1 is 2.13% faster than Test2
Output for 5.4.41
Test1 is 1.17% faster than Test2
Output for 5.4.40
Test2 is 6.58% faster than Test1
Output for 5.4.39
Test2 is 14.58% faster than Test1
Output for 5.4.38
Test2 is 4.41% faster than Test1
Output for 5.4.37
Test2 is 6.23% faster than Test1
Output for 5.4.36
Test2 is 5.67% faster than Test1
Output for 5.4.35
Test2 is 27.09% faster than Test1
Output for 5.4.34
Test2 is 9.5% faster than Test1
Output for 5.4.32
Test1 is 5.12% faster than Test2
Output for 5.4.31
Test2 is 1.59% faster than Test1
Output for 5.4.30
Test2 is 2.02% faster than Test1
Output for 5.4.29
Test1 is 7.1% faster than Test2
Output for 5.4.28
Test2 is 11.84% faster than Test1
Output for 5.4.27
Test2 is 3.74% faster than Test1
Output for 5.4.26
Test2 is 4.87% faster than Test1
Output for 5.4.25
Test1 is 1.32% faster than Test2
Output for 5.4.24
Test1 is 3.52% faster than Test2
Output for 5.4.23
Test2 is 6.98% faster than Test1
Output for 5.4.22
Test2 is 0.93000000000001% faster than Test1
Output for 5.4.21
Test2 is 0.65000000000001% faster than Test1
Output for 5.4.20
Test1 is 1.96% faster than Test2
Output for 5.4.19
Test1 is 6.2% faster than Test2
Output for 5.4.18
Test1 is 2.77% faster than Test2
Output for 5.4.17
Test1 is 0.53% faster than Test2
Output for 5.4.16
Test2 is 14.53% faster than Test1
Output for 5.4.15
Test2 is 2.9% faster than Test1
Output for 5.4.14
Test2 is 5.84% faster than Test1
Output for 5.4.13
Test2 is 1.76% faster than Test1
Output for 5.4.12
Test2 is 11.26% faster than Test1
Output for 5.4.11
Test2 is 8.15% faster than Test1
Output for 5.4.10
Test1 is 3.58% faster than Test2
Output for 5.4.9
Test2 is 12.87% faster than Test1
Output for 5.1.6, 5.4.8
Test2 is 0.40000000000001% faster than Test1
Output for 5.4.7
Test2 is 1.26% faster than Test1
Output for 5.4.6
Test1 is 4.11% faster than Test2
Output for 5.4.5
Test1 is 4.22% faster than Test2
Output for 5.4.4
Test1 is 5.47% faster than Test2
Output for 5.4.3
Test1 is 7.25% faster than Test2
Output for 5.4.2
Test1 is 1.59% faster than Test2
Output for 5.4.1
Test2 is 0.079999999999998% faster than Test1
Output for 5.4.0
Test1 is 7.15% faster than Test2
Output for 5.3.29
Test2 is 8.19% faster than Test1
Output for 5.3.28
Test2 is 8.81% faster than Test1
Output for 5.3.27
Test1 is 0.95999999999999% faster than Test2
Output for 5.3.26
Test1 is 1.27% faster than Test2
Output for 5.3.25
Test2 is 7.96% faster than Test1
Output for 5.3.23
Test2 is 2.19% faster than Test1
Output for 5.3.22
Test2 is 8.25% faster than Test1
Output for 5.3.21
Test1 is 0.44% faster than Test2
Output for 5.3.20
Test1 is 0.41% faster than Test2
Output for 5.3.19
Test1 is 4.34% faster than Test2
Output for 5.3.18
Test2 is 2.53% faster than Test1
Output for 5.3.17
Test2 is 6.72% faster than Test1
Output for 5.3.16
Test1 is 2.75% faster than Test2
Output for 5.3.15
Test1 is 5.13% faster than Test2
Output for 5.3.14
Test2 is 11.97% faster than Test1
Output for 5.3.13
Test1 is 5.34% faster than Test2
Output for 5.3.12
Test2 is 1.51% faster than Test1
Output for 5.3.11
Test2 is 7.99% faster than Test1
Output for 5.3.10
Test1 is 2.89% faster than Test2
Output for 5.3.9
Test1 is 3.37% faster than Test2
Output for 5.3.8
Test2 is 8.26% faster than Test1
Output for 5.3.7
Test2 is 4.39% faster than Test1
Output for 5.3.6
Test2 is 0.019999999999996% faster than Test1
Output for 5.3.5
Test2 is 8.94% faster than Test1
Output for 5.3.4
Test1 is 3.85% faster than Test2
Output for 5.3.3
Test1 is 1.94% faster than Test2
Output for 5.3.2
Test2 is 6.21% faster than Test1
Output for 5.3.1
Test2 is 6.92% faster than Test1
Output for 5.3.0
Test2 is 2.77% faster than Test1
Output for 5.2.17
Test1 is 3.46% faster than Test2
Output for 5.2.16
Test1 is 6.48% faster than Test2
Output for 5.2.15
Test2 is 5.01% faster than Test1
Output for 5.2.14
Test2 is 10.61% faster than Test1
Output for 5.2.13
Test1 is 0.97% faster than Test2
Output for 5.2.11
Test1 is 0.22% faster than Test2
Output for 5.2.10
Test2 is 3.17% faster than Test1
Output for 5.2.9
Test1 is 0.010000000000005% faster than Test2
Output for 5.2.8
Test1 is 1.61% faster than Test2
Output for 5.2.7
Test1 is 2.65% faster than Test2
Output for 5.2.6
Test1 is 1.19% faster than Test2
Output for 5.2.5
Test1 is 3.65% faster than Test2
Output for 5.2.4
Test2 is 3.96% faster than Test1
Output for 5.2.3
Test2 is 0.27% faster than Test1
Output for 5.2.2
Test2 is 8.57% faster than Test1
Output for 5.2.1
Test2 is 1.74% faster than Test1
Output for 5.2.0
Test2 is 1.33% faster than Test1
Output for 5.1.5
Test2 is 4.55% faster than Test1
Output for 5.1.4
Test2 is 4.17% faster than Test1
Output for 5.1.3
Test2 is 15.4% faster than Test1
Output for 5.1.2
Test2 is 2% faster than Test1
Output for 5.1.1
Test2 is 4.27% faster than Test1
Output for 5.1.0
Test1 is 4.36% faster than Test2
Output for 5.0.5
Test1 is 8.72% faster than Test2
Output for 5.0.4
Test2 is 7.03% faster than Test1
Output for 5.0.3
Test1 is 5.38% faster than Test2
Output for 5.0.2
Test2 is 8.35% faster than Test1
Output for 5.0.1
Test1 is 6.82% faster than Test2
Output for 5.0.0
Test1 is 0.5% faster than Test2
Output for 4.4.9
Test2 is 176.66% faster than Test1
Output for 4.4.8
Test2 is 167.12% faster than Test1
Output for 4.4.7
Test2 is 174.34% faster than Test1
Output for 4.4.6
Test1 is 7% faster than Test2
Output for 4.4.5
Test1 is 4.77% faster than Test2
Output for 4.4.4
Test2 is 180.56% faster than Test1
Output for 4.4.3
Test2 is 197.74% faster than Test1
Output for 4.4.2
Test2 is 182.66% faster than Test1
Output for 4.4.1
Test2 is 183.16% faster than Test1
Output for 4.4.0
Test2 is 171.61% faster than Test1
Output for 4.3.11
Test2 is 188.05% faster than Test1
Output for 4.3.10
Test2 is 188.68% faster than Test1
Output for 4.3.9
Test1 is 0.43000000000001% faster than Test2
Output for 4.3.8
Test2 is 188.07% faster than Test1
Output for 4.3.7
Test2 is 184.4% faster than Test1
Output for 4.3.6
Test2 is 184.83% faster than Test1
Output for 4.3.5
Test2 is 171.48% faster than Test1
Output for 4.3.4
Test2 is 188.96% faster than Test1
Output for 4.3.3
Test2 is 179.77% faster than Test1
Output for 4.3.2
Test2 is 196.61% faster than Test1
Output for 4.3.1
Test2 is 173.45% faster than Test1
Output for 4.3.0
Test2 is 181.32% faster than Test1