Basically, which is faster:
Code: Select all
check_auth();Code: Select all
$checker = new login();
$checker->check_auth();Moderator: General Moderators
Code: Select all
check_auth();Code: Select all
$checker = new login();
$checker->check_auth();I did a quick test with the code you posted, expecting the function to be marginally faster. Turns out, the class on average was faster by around .0000527 (10 trials). That's 52.7 millionths of a second faster, by the way.computernoob wrote:So which one is faster?
So... you're advocating smaller classes?Raimo Roopertti wrote:ALWAYS!
Since the introduction of classes, many have developed huge classes to do many kinds of "things", believing they make things easy.
I didn't build my car either...Raimo Roopertti wrote:1. Since you have not written the class, you do not know exactly how it works.
Got it. I will use TWO functions (methods?) from now on.Raimo Roopertti wrote:2. You are loading a huge amount of code (that needs to be processed), just to load your class. Then you use ONE function of that class! Ludicrous!
Agreed, no moderate use of objects here. Go big or go home.Raimo Roopertti wrote:So, unless you intend to use the class INTENSIVELY, and for several similar objects, throughout your code, don't bother!
Yeah, just don't bother. You know you'll never need it in the future, who reuses code anymore these days?Raimo Roopertti wrote:Same if you need the class only once.
allspiritseve wrote:Got it. I will use TWO functions (methods?) from now on.Raimo Roopertti wrote:2. You are loading a huge amount of code (that needs to be processed), just to load your class. Then you use ONE function of that class! Ludicrous!