@benjarriola Actually, in PHP, a while loop will run faster. But the gain is not significant at all(something such as 0.001 seconds for 100000 iterations...), so it's not worth changing all your for loops for while in your scripts
It should also be added that, benchmarking to the millisecond difference is actually EXTREMELY hard to do - background processes on a server, anything can cause these so-called 'benchmarks' to be off. Iterating a thousand times isn't a real benchmark.
FYI: The official php developers have refuted these tips as false. Single vs. Double quotes is an age old argument and they're a wash - if not doubles are faster.
Echo vs. Print is another one, his reason for doing so is a little off - if anything print -could- be slower because it returns 1, echo doesn't bother to return.
These were the most insignificant performance tips ever to exist. Your benchmark towards the end was laughable. I'll bet you $100 you can't find a noticeable performance gain using these.
Proper performance tips include "caching database results", "using an op-code cache (APC)", "re-factoring loops", etc.
Actually, anything that what wasn't on the video would of been more useful.
And the first example is priceless. "Imagine if a malicious user had inserted 512Kb worth of characters". Yeah, right, but the real issue is an obvious cross-scripting vulnerability. What a wonderful example.
And as pointed out by Noobenstein, PHP does COW for variables.
This is nothing but misinformation. It must be a joke, I can't believe this video has been made by Google.
And the first example is priceless. "Imagine if a malicious user had inserted 512Kb worth of characters". Yeah, right, but the real issue is an obvious cross-scripting vulnerability. What a wonderful example.
And as pointed out by Noobenstein, PHP does COW for variables.
This is nothing but misinformation. It must be a joke, I can't believe this video has been made by Google.
@realluinnar Wrong. At that point, you're going into load-balancing, DB tuning and caching of all sorts; and if that fails, improve your algorithms. Do you think it makes a difference if a server is 99% or 98% loaded?
@mescaline99 Maybe changing existing code it not a good thing to do depending on the complexity of the program. And if it is short running program, changing this may not really help that much. I see benefits in doing this when I have nested loops. Anything I can do within the loops, even if they look small, you see significant changes in speed.
Aside from that, I think this lesson was to teach you a good practice on what to do in new applications you make.
Actually, if the original execution time was 0.02 seconds, then you would just have doubled the performance! It's the relative improvement which matters.
But as the article itself points out, "Premature optimization is the root of all evil". I'd like see some before/after benchmarks on this...
One it comes to millions of hits per day then I would say it's a pretty major factor, that said, things like caching are more essential. At the very least tips like this should help encourage good coding practice.
This video its for someone as big as google!, this must be emailed to microsoft instead of make us watching it :D
hellmind 1 month ago in playlist Más vídeos de GoogleWebmasterHelp
apple
zxrug 7 months ago
yeah thats ooo
zxrug 7 months ago
Due to Rasmus Lerdorf single-qoutes doens't make your code run faster than double. It's just a myth.
x264 7 months ago
Have any of you ever coded a webapp with Python? Python (as a whole) is supposedly faster than PHP even. :)
roejames12 1 year ago
so, you use mysql_* , and try to teach others something... how pathetic.
RWOverdijk 1 year ago
If you have a while loop and a for loop that run the same thing, a for loop runs faster?
benjarriola 1 year ago
@benjarriola Actually, in PHP, a while loop will run faster. But the gain is not significant at all(something such as 0.001 seconds for 100000 iterations...), so it's not worth changing all your for loops for while in your scripts
HCkev 9 months ago
Wait. That's it?
mcbwebdesign 1 year ago 2
I was forced to watched this video because utube kept recommending this to me lol
cici254 1 year ago 2
lol I actually thought that this google guy was serious for a moment...
wait...
he is...
thats just so sad... and wrong...
l33tnasty 2 years ago 3
Never expected this from google, very bad.
vaazstorm 2 years ago
It should also be added that, benchmarking to the millisecond difference is actually EXTREMELY hard to do - background processes on a server, anything can cause these so-called 'benchmarks' to be off. Iterating a thousand times isn't a real benchmark.
jrovang 2 years ago
FYI: The official php developers have refuted these tips as false. Single vs. Double quotes is an age old argument and they're a wash - if not doubles are faster.
Echo vs. Print is another one, his reason for doing so is a little off - if anything print -could- be slower because it returns 1, echo doesn't bother to return.
jrovang 2 years ago
This comment has received too many negative votes show
The easiest way to speed up a PHP script is stop using PHP.
Usien6 2 years ago
These were the most insignificant performance tips ever to exist. Your benchmark towards the end was laughable. I'll bet you $100 you can't find a noticeable performance gain using these.
Proper performance tips include "caching database results", "using an op-code cache (APC)", "re-factoring loops", etc.
Actually, anything that what wasn't on the video would of been more useful.
ThePixelDeveloper 2 years ago 4
Dear Eric, don't put this video on your resume. It might make you look like an amateur, even though you have eight years of experience.
klimpong 2 years ago 2
This has been flagged as spam show
It must be a joke.
Does Google actually use... PHP?
And the first example is priceless. "Imagine if a malicious user had inserted 512Kb worth of characters". Yeah, right, but the real issue is an obvious cross-scripting vulnerability. What a wonderful example.
And as pointed out by Noobenstein, PHP does COW for variables.
This is nothing but misinformation. It must be a joke, I can't believe this video has been made by Google.
Real PHP performance tip: use PHP-FPM.
jedisct1 2 years ago
It must be a joke.
Does Google actually use... PHP?
And the first example is priceless. "Imagine if a malicious user had inserted 512Kb worth of characters". Yeah, right, but the real issue is an obvious cross-scripting vulnerability. What a wonderful example.
And as pointed out by Noobenstein, PHP does COW for variables.
This is nothing but misinformation. It must be a joke, I can't believe this video has been made by Google.
Real PHP performance tip: use PHP-FPM.
jedisct1 2 years ago
What's the speed increase? Like 0.01 seconds..
zomgomgomgz 2 years ago
even less than that, it's so infinitesimal that's it's not worth editing your code over. I'm actually disappointed Google posted this.
mescaline99 2 years ago 13
When you have site with 1kk users/month and more every millisecond is important
realluinnar 2 years ago
@realluinnar Wrong. At that point, you're going into load-balancing, DB tuning and caching of all sorts; and if that fails, improve your algorithms. Do you think it makes a difference if a server is 99% or 98% loaded?
demonkoryu 11 months ago
@mescaline99 Maybe changing existing code it not a good thing to do depending on the complexity of the program. And if it is short running program, changing this may not really help that much. I see benefits in doing this when I have nested loops. Anything I can do within the loops, even if they look small, you see significant changes in speed.
Aside from that, I think this lesson was to teach you a good practice on what to do in new applications you make.
benjarriola 1 year ago
Actually, if the original execution time was 0.02 seconds, then you would just have doubled the performance! It's the relative improvement which matters.
But as the article itself points out, "Premature optimization is the root of all evil". I'd like see some before/after benchmarks on this...
jusssih 2 years ago
Does anyone know what PHP editor he is using in this video?
Wadetrain 2 years ago
vim i suppose
lukas0907 2 years ago 4
I'd rather use double quotes for long strings that need lots of variables because it makes the code more readable.
I guess these tips only apply if you're expecting a million hits per day or something. Otherwise, it's not worth the hassle.
simoncpu 2 years ago 2
Could you do one on ASP performance tips
aish1108 2 years ago
How to speed up ASP performance:
Switch to PHP. :^P
shanedk 2 years ago 31
Lets be realistic these tips are really a minor factor in performance. Good caching is essential.
wagawuga 2 years ago 3
One it comes to millions of hits per day then I would say it's a pretty major factor, that said, things like caching are more essential. At the very least tips like this should help encourage good coding practice.
traxdata2k 2 years ago
This comment has received too many negative votes show
Very interesting! A lot of videos from google on speed today hehe
Conceptskatemedia 2 years ago