<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Sep 25, 2014 at 12:17 AM, Hugues Peccatte <span dir="ltr"><<a href="mailto:hugues.peccatte@gmail.com" target="_blank">hugues.peccatte@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><span class="">2014-09-24 14:42 GMT+02:00 Chirayu Chiripal <span dir="ltr"><<a href="mailto:chirayu.chiripal@gmail.com" target="_blank">chirayu.chiripal@gmail.com</a>></span>:</span><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><span class=""><div class="gmail_quote"><div><div><div><br></div></div></div><div>I was just wondering what will be the effect if we make current methods as static in those classes?<br></div></div></span><span><br>-- <br><span class=""><div dir="ltr">Regards,<br>Chirayu Chiripal<br><a href="https://chirayuchiripal.wordpress.com/" target="_blank">https://chirayuchiripal.wordpress.com/</a></div></span></span></div></div></blockquote><div><br></div><div>It's almost the same thing to use a static or a non-static function. This is 2.5x slower than standard PHP function.</div><div><br></div><div>See:</div><div><div>Time: 1.7506999969482 //standard PHP function</div><div>Time: 4.3722500801086 //object</div><div>Time: 4.3722498416901 //object with static function</div><div>Time: 3.6722099781036 //PMA function, even this one is 2x slower than standard PHP function…</div></div></div></div></div></blockquote><div><br>Are these tests performed on mb_* function or non mb_* one?<br><br></div><div>One thing is clear from these results is that even wrapping a built in function in another function (wrapper function) has some significant overhead. And using OOP/Classes is like wrapping that wrapper function further into a another wrapper causing further slowness. So why not just use mb_* function directly everywhere? If we do this, then what to do in case mb_* functions are not available? Maybe we can just define a new mb_* function to use respective non mb_* function for it. For e.g.<br></div><div>// Define a function like this<br></div><div>function mb_strlen($str) {<br></div><div> return strlen($str);<br></div><div>}<br>// or create an alias of strlen() as mb_strlen() (I heard this is possible in PHP 5.6+)<br><br></div><div>By doing this, we can get speed advantage of built in mb_* function whenever it is available by avoiding any wrapper function or class. And in cases where it is not available, a wrapper function with standard non mb function can deliver equivalent performance as non mb function is inherently faster than its mb_* mod.<br></div><div> <br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><span class=""><font color="#888888"><div><br></div><div>Hugues.</div></font></span></div></div></div>
<br></blockquote></div></div></div>