PHP quicker Query
Re: PHP quicker Query
When it comes to variable names, the standard is more like writing them out so you understand what it means (self-documenting). $VoD is an example of bad practice, as it doesn't mean anything to most people. Of course, if the abbreviation is widespread, and makes sense in the context, go for it, but some kind of middle ground would be best to go for. A variable name doesn't really require that much processing power. The bottlenecks I usually encounter comes into play when I work with the database, especially when gathering data.
Re: PHP quicker Query
I use PSPad for editing, so my variable names have a nice little box on the right I can make sure I know what they all look like, I'm also a terrible speller so my most common errors in programming is spelling the Variable correctly. Also I'm lazy.. writing the same variable name over and over can be annoying, but 2-3 letters is easier.
Lastly while naming conventions for Java are full named with Capital letters for the 2nd word onwards (i.e. programThatMakesThingsGood() ) its because the compiled just turns it into f0, f1, f2 etc when it compiles
but PHP is not a compiled script, so the naming conventions are .. unhealthy? I typically write my PHP like I do Java, and have ALOT of comments, then when I have a working version that I doubt I will change much later, I strip all the comments, cut all my Variable names to 3letter combinations (or even v1, v2, v3 etc) and upload that so its as small as possible.
I know this is just me.. no need for people to copy everything I'm writing just because I do.
Lastly while naming conventions for Java are full named with Capital letters for the 2nd word onwards (i.e. programThatMakesThingsGood() ) its because the compiled just turns it into f0, f1, f2 etc when it compiles
but PHP is not a compiled script, so the naming conventions are .. unhealthy? I typically write my PHP like I do Java, and have ALOT of comments, then when I have a working version that I doubt I will change much later, I strip all the comments, cut all my Variable names to 3letter combinations (or even v1, v2, v3 etc) and upload that so its as small as possible.
I know this is just me.. no need for people to copy everything I'm writing just because I do.
- Jackolantern
- Posts: 10891
- Joined: Wed Jul 01, 2009 11:00 pm
Re: PHP quicker Query
Do you keep a copy with the full variable names and comments on your computer? Otherwise, you are basically dooming yourself to not understanding a bit of it in 6 months or a year when you go back to work on it again. Heck, I wouldn't have been able to understand parts of my game I wrote even 2 months ago if it was not for very detailed variable names and tons of comments.
Also, double-slash comments are negligible on processing time. Once the parser sees "//", it skips the line. So the only benefit you are getting is smaller file sizes on the server HDD, which is likely not of much importance.
Also, double-slash comments are negligible on processing time. Once the parser sees "//", it skips the line. So the only benefit you are getting is smaller file sizes on the server HDD, which is likely not of much importance.
The indelible lord of tl;dr
- hallsofvallhalla
- Site Admin
- Posts: 12026
- Joined: Wed Apr 22, 2009 11:29 pm
Re: PHP quicker Query
comments make no difference whatsoever on parsed code.
Also the difference between a 3 letter variable and a 6 letter variable would only be noticeable if you have several hundred variables looping on one page and you were on a 486/dx, 8 megs ram, and a 14.4k bps modem
Also the difference between a 3 letter variable and a 6 letter variable would only be noticeable if you have several hundred variables looping on one page and you were on a 486/dx, 8 megs ram, and a 14.4k bps modem

Re: PHP quicker Query
No wonder why my inter net is slow I thought it was just my internet provider halls 

- hallsofvallhalla
- Site Admin
- Posts: 12026
- Joined: Wed Apr 22, 2009 11:29 pm
Re: PHP quicker Query
hehe yeah you should upgrade that 486sx to a 486DX2!!! hehehehe
- Jackolantern
- Posts: 10891
- Joined: Wed Jul 01, 2009 11:00 pm
Re: PHP quicker Query
LOL You just described my first "real PC" almost to the letter. Except that it came with 4 megs of RAM, which I then upgraded to 8 megs. I also only had a 2400 baud modem lol. I don't think 14k modems were around yet.
The indelible lord of tl;dr
- hallsofvallhalla
- Site Admin
- Posts: 12026
- Joined: Wed Apr 22, 2009 11:29 pm
Re: PHP quicker Query
I also had the same PC with 4 megs ram, cost me $80 to upgrade to 8 megs, 

Re: PHP quicker Query
Yeah I keep full copies of the 'slow' version. I upload both versions (incase god forbid, I lose the original) and save the back up version in a separate secure folder.Jackolantern wrote:Do you keep a copy with the full variable names and comments on your computer? Otherwise, you are basically dooming yourself to not understanding a bit of it in 6 months or a year when you go back to work on it again. Heck, I wouldn't have been able to understand parts of my game I wrote even 2 months ago if it was not for very detailed variable names and tons of comments.
Also, double-slash comments are negligible on processing time. Once the parser sees "//", it skips the line. So the only benefit you are getting is smaller file sizes on the server HDD, which is likely not of much importance.
If you want to check for yourselves, Heres a Pseudo Script
Code: Select all
Function checkTimeConcept($Data, $comment) {
Store Time in Variable $time
Run Loop ($i to 100,000) {
$($Data) = 'bobs auto parts"
if ($comment) { // This is a comment }
}
$GrabTime = current Time - stored time
return $grabtime
}
Then Add a few Calls
Code: Select all
echo CheckTimeConcept(varN, FALSE)
echo CheckTimeConcept(mediumVariableName, FALSE)
echo CheckTimeConcept(frigginHugeVariableNameThatShouldNotEffectProcesButDoes, FALSE)
echo CheckTimeConcept(checkSlash, TRUE)
Base0.142134904861
standard Small Variable0.300375938416
standard Medium Variable0.367891073227
VeryLarge Variable0.602063894272
- PaxBritannia
- Posts: 680
- Joined: Sun Apr 18, 2010 1:54 pm
Re: PHP quicker Query
Personally, I think crap Database structuring and over-querying is the main concern with all php/mysql scripts.
For example: sing sort by rand() is actually very inefficient.
Pax.
For example: sing sort by rand() is actually very inefficient.
Pax.