markjoe Posted March 19, 2009 Share Posted March 19, 2009 I am maintaining a large PHP app, and am trying to squeeze every last bit of performance out of it. (as it is painfully slow as is) I am looking for some efficiency tips, surprisingly google has turned up nothing for me, and I know there are good PHP'ers here. Here's my contribution, I've done some simple benchmarks on a few common issues I know. $x1=abcdefghijklmnopqrstuvwxyz substr($x1,n,1): 0.7362 seconds (225.3%), value=t $x1{n}: 0.326759 seconds (44.38%), value=t $x2=123456abcdef intval($x2): 0.572915 seconds (195.06%), value=123456 (int)$x2: 0.293719 seconds (51.27%), value=123456 $x3=array(a,b,c,d) split(',',$x3): 2.54544 seconds (158.36%), value=Array ( [0] => a [1] => b [2] => c [3] => d ) explode(',',$x3): 1.607407 seconds (63.15%), value=Array ( [0] => a [1] => b [2] => c [3] => d ) I can further explain that if it doesn't make sense. Anybody else have any suggestions or ideas? Quote Link to comment https://forums.phpfreaks.com/topic/150095-fine-efficiency-in-php/ Share on other sites More sharing options...
sKunKbad Posted March 19, 2009 Share Posted March 19, 2009 You'll probably find that a large app that is slow will need more than a little tweaking to become efficient. You may find yourself rewriting the whole thing. Quote Link to comment https://forums.phpfreaks.com/topic/150095-fine-efficiency-in-php/#findComment-788237 Share on other sites More sharing options...
markjoe Posted March 19, 2009 Author Share Posted March 19, 2009 Unfortunately, a full rewrite isn't going to happen. for many reasons... I'm looking at rewriting functions that get called thousands of times and optimizing all database joins. Besides, even if I were to rewrite it, I would still want to know the most efficient way of doing things. This topic isn't only about how I can shave a couple seconds off the load times for this project, it's about overall efficiency. I don't just want code that works, I want code that works as well as it possibly can. Quote Link to comment https://forums.phpfreaks.com/topic/150095-fine-efficiency-in-php/#findComment-788250 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.