Does php run faster without warnings?

I bookmarked an article in which the author did some benchmarks about that ; unfortunatly, it’s in french… but here it is (maybe you’ll understand some parts of it) : Ne faites pas d’erreur

And here are the numbers, to help people who don’t read french :

  • 10k notices, with error_reporting and display_errors enabled : 5,162.76 ms
  • same, but with display_errors disabled : 136.18 ms
  • same, but with error_reporting disabled too : 117.79 ms
  • and, finally, after patching the code so it doesn’t produce any notice anymore : 19.51 ms

Which means that, yes, PHP code runs faster without notices/warnings/errors, even when those are not displayed nor reported.

Derick Rethans says the same thing in this article : Five reasons why the shut-op operator (@) should be avoided (quoting) :

Reason 3: It’s slow (part 2)

Whenever PHP generates an error
message internally, it’s processed and
formatted all the way up to the fully
formatted message that can be
outputted straight to the browser.
Only just before it is displayed the
error_reporting setting is checked.
This however, is not related to the
@-operator exclusively.
The error
message is just always fully formatted
before error_reporting is checked—or
display_errors for that matter.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)