3v4l.org

run code in 300+ PHP versions simultaneously
<?php // Simple: $start = microtime(true); for($i = 0; $i < 10000000; $i++) { $a = 1 + 2; } echo 'Simple: ' . microtime(true) - $start; // Separate function: $start = microtime(true); function add() { return 1 + 2; } for($i = 0; $i < 10000000; $i++) { $a = add(); } echo "\n\nSeparate function: " . microtime(true) - $start; // Wrapped in {...} $start = microtime(true); for($i = 0; $i < 10000000; $i++) { { $a = 1 + 2; } } echo "\n\nWrapped in {...}: " . microtime(true) - $start; // IIFE $start = microtime(true); for($i = 0; $i < 10000000; $i++) { $a = (function() { return 1 + 2; })(); } echo "\n\nWrapped in IIFE: " . microtime(true) - $start;

preferences:
34.74 ms | 404 KiB | 5 Q