3v4l.org

run code in 300+ PHP versions simultaneously
<?php $iterations = 1_000_000; class Result { } benchmark('Result object', fn() => new Result()); benchmark('Exceptions', fn() => throw new \RuntimeException()); function benchmark(string $label, \Closure $closure) { global $iterations; $sT = microtime(true); for ($i = 0; $i < $iterations; $i ++) { try { $closure(); } catch (\Exception $e) { } } echo $label . ' : ' . (microtime(true) - $sT) . 's' . PHP_EOL; }

preferences:
33.81 ms | 402 KiB | 5 Q