supressing errors is really slow |
[eluser]xwero[/eluser]
I've did a quick and dirty benchmark Code: $end = 10; 1 time result @ time : 0.0001 if time: 0.0000 10 times result @ time : 0.0003 if time: 0.0000 100 times result @ time : 0.0023 if time: 0.0001 1000 times result @ time : 0.0226 if time: 0.0014 There is quite some suppressing in CI's code so i start to wonder is it really necessary or is there alternative, faster code?
[eluser]webthink[/eluser]
That's a pretty severe slowdown you're showing there. 16 times slower over 1000 cycles even though you've added a conditional. I did a quick google and can't find any resources that talk about this. (It's a php issue as well as a CI issue so you'd think there would be some information out there) I'm all for speeding things up regardless of how small the gain may be. I think in general using the @operator is not good practice and should be avoided. I haven't had a chance to look for any of these instances in the CI code could you point me in the direction of a few examples? Are they mostly like your example where they're used to avoid a notice from using a bad array index?
[eluser]xwero[/eluser]
The database drivers all suppress the function errors. I'm not sure if there is code like my example, but i remember there was one library where i saw it too be i can't remember which one it was.
[eluser]xwero[/eluser]
I'm not sure if this is a solution but if you define an error_reporting level in the bootstrap file and in the database driver methods you do Code: function db_connect()
[eluser]m4rw3r[/eluser]
function_exists()? Code: function db_connect()
[eluser]xwero[/eluser]
No function_exist doesn't stop the errors from appearing. That is the problem. Even if you have an error handler the error gets shown.
[eluser]xwero[/eluser]
Benchmarks on the error_reporting solution Code: $end = 1000; 1 time result @ time : 0.0001 error_reporting time: 0.0000 10 times result @ time : 0.0003 error_reporting time: 0.0003 100 times result @ time : 0.0022 error_reporting time: 0.0027 1000 times result @ time : 0.0222 error_reporting time: 0.0266 so that's even worse than suppressing errors.
[eluser]xwero[/eluser]
I've made a modification of the last snippet and put the error_reporting functions outside the loop and it got me this result when looped 1000 times @ time : 0.0222 error_reporting time: 0.0191 Are there benchmark nuts here who can tell if these numbers actually matter?
[eluser]m4rw3r[/eluser]
Does mysqli_connect raise PHP errors? I thought it only raised errors if it doesn't exists (which is very disturbing, no explanation why the db doesn't work, only a blank page).
[eluser]xwero[/eluser]
yes database functions all throw a E_WARNING error if a database error occurs, that is why they are suppressed. |
Welcome Guest, Not a member yet? Register Sign In |