Jump to content

Recommended Posts

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?

Link to comment
https://forums.phpfreaks.com/topic/150095-fine-efficiency-in-php/
Share on other sites

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.