3 simple rules for you to get it right:
- No syntax issue can affect performance. Data manipulation does.
- Speak of performance only backed with results of profiling.
- Premature optimization is the root of all evil
Performance issues are quite hard to understand. It is advised for the newbies not to take it into account. Because they are always impressed with trifle things and fail to see a real important things. Just because lack of experience.
Same for your question. Imagine you'll ever get some difference. Even big one, say, one method is 2 times faster. Oh my, 2 times! I choose it and optimized my app well, it will run 50% faster now!
Wrong. Not 50%. You'd never notice or even measure this speed increase. Because you optimized a part that take only 0,0001% of whole script runtime.
As for the big HTML tables, it take a long time for the browser to render it. Much more than you took to generate.
Profiling is a key word in the performance world. One can trash any performance related question with no doubts if there is no word "profiling" in it.
At the same time profiling is not a rocket science. It's just measuring of runtime of different parts of your script. Can be done with some profiler, like xdebug, or even manually, using microtime(1)
. And only after detecting the slowest part, may you start with tests.
Learn to profile before asking performance questions.
And learn not to ask performance questions if there is no real reasons for it.
Premature optimization is the root of all evil - D.Knuth.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…