PHP Optimization Tips #9

Check out my other PHP optimization tips by clicking on the Optimization category.

A common myth amongst programmers is the use of comments in the script file. Although very useful, some believes that it actually slows down the script. I checked this out for myself today.

Here’s the results:

Time Memory Usage
Control Average 0.83961215 144
Inline Comments 0.90110895 144
Multiline Comments 0.91172699 144
Both Comments 0.91420751 144

As you can see there are slightly different values for the inline, multiline comments. Now, I’m not a PHP source code expert, I don’t know how the comments are exactly parsed by the engine, but the script file with the comments is a littlebit slower than the file without it.

What is interesting that when I first ran the script files with the comments, no matter if it was an inline or multiline comment, the script took above 1 second to finish. I suppose this is where PHP converts the script file and caches it…

I leave this optimization up to you to decide. I surely will use comments in my code for better management, the difference in the results are too tiny…

I used PHP 5.2.5 and Apache 2.0.63 without any memcache or any other optimizer installed.

One last thought, in the production enviroment it is advised that we optimize the code as much as we can. We can, and we should create code that optimizes our source and deploying it from development or from staging enviroment into production.

Little Thoughts on Determination

Why people do what they do?

Why most of the people work, but they don’t enjoy what they do?

The simple answer would be, because they don’t have the guts. They don’t have the guts to quit their jobs, reorganize their life. They just simply looking at it and how it goes by in front of them.

I had the opportunity to see such people, heck I was one of them. But one day I told myself, it’s enough. I won’t do things that I don’t like anymore. I mean things that are affecting my life, not things like going to buy milk on a Sunday afternoon :-)

I’m not here to talk about, or to convince you that what you’re doing (and you don’t like it) is probably wrong, Leo Babauta from zenhabits could tell you one thing or two :-)

I’m simply writing that most people don’t have the guts to make their life better, to live on a tropical island serving cocktails for turists for ex.

And why? The fact is school really kills creativity in people which is a sad thing. People are afraid of the unknown, because from giving up your day job to making your dreams come true is somewhat a long, dangerous and unknown path that everyone must walk through.

And I don’t want to write big words and big thoughts here, but I honestly consider that is the problem. If anybody has more thoughts on this then you’re welcome to comment on this post.

Enjoy.

Why MySQL is a piece of crap

Because the InnoDB doesn’t support FULLTEXT. This can be used with MyISAM.

And MyISAM doesn’t support foreign key constraints, this can be used with InnoDB.

And I need both. I didn’t figured out how to do it just yet. So if anybody knows please let me know in the comments.

Thanks.

One thing that’s common in all browsers

I found one thing that is common in all the browsers, no matter the platform, version or company.

It is the CTRL+T hotkey for opening new tabs. Of course this is where tabs are available.

Sad. Also visit and help http://savethedevelopers.org/