0

Being self taught I lack in the area of theory. I recently wrote a ton of functions to render forms to speed up my development, but I was wondering if functions slow loading time verses simply having the code directly on the page?

petebolduc
  • 1,233
  • 1
  • 13
  • 20
  • 7
    It'll be fractionally slower to execute (there is an overhead in a function call) but it should be a lot more readable and maintainable – Mark Baker Mar 01 '14 at 13:01
  • Pete have a look at here, this may be helpful: http://stackoverflow.com/questions/6495030/java-how-expensive-is-a-method-call – Anto Mar 01 '14 at 13:02
  • From a different perspective... is a function call faster or slower than an include... I am writing a cms and want to maintain the ability to make changes on these forms from a single location. – petebolduc Mar 01 '14 at 13:22

2 Answers2

1

Apart from having a hundred-call stack, there will be no real performance issue by writting functions. However, it is really easier to develop by splitting your code into some parts.

artragis
  • 3,677
  • 1
  • 18
  • 30
-1

Functions in PHP do come with a performance hit, so if you are concerned with the efficiency of your code you could avoid them to improve it.

http://www.tuxradar.com/practicalphp/18/1/3

duncan3dc
  • 248
  • 1
  • 5
  • Please refrain from posting nonsense links thank you – Your Common Sense Mar 01 '14 at 13:27
  • thanks for the feedback... good article... another vote for not using wordpress. – petebolduc Mar 01 '14 at 13:27
  • 1
    @YourCommonSense What is nonsense about it? It points out the performance hit of functions, and explains that it should only be used as a last resort to squeeze a bit more performance out of a script – duncan3dc Mar 01 '14 at 13:45
  • 1
    #duncan3dc In a world where Google expects a page to load in a half a second every little bit counts. It all boils down to a give and take in relation to performance verses maintainability. I do not understand the negative vote you received as the article directly was pertinent to the question... thanks – petebolduc Mar 01 '14 at 13:56
  • There is one problem with this test. One who tests, have to have an idea, how to test and what he is testing. This guy doesn't. In reality there is no performance hit. – Your Common Sense Mar 01 '14 at 13:57
  • @Your Common Sense... Thank you for your clarification. I love this site because it provides the self-taught guy like myself an effective avenue to learn from expert programmers who are willing to share in record time... perhaps the clarifying statement would of more beneficial if it had been in your first comment... Thank you for your input. – petebolduc Mar 01 '14 at 14:11
  • @petebolduc oh, no. This site provides the self-taught guy like yourself with some superstitions and bad practices only. And you are little mistaken about "expert programmers". – Your Common Sense Mar 01 '14 at 14:16
  • @Your Common Sense... so in your opinion should I concern myself with performance issues of functions and/or would using includes be better since these forms are used in numerous in the back end administration? – petebolduc Mar 01 '14 at 14:29
  • @petebolduc oh. If you *really* interested in my opinion, then just [don't bother yourself with performance issues at all](http://stackoverflow.com/questions/2437144/opening-closing-tags-performance/2437413#2437413) and don't ask questions out of nowhere, with no reason. – Your Common Sense Mar 01 '14 at 14:31
  • @Your Common Sense... final comment... thank you again for the link... it was beneficial. When one has extensive knowledge in an area, they often forget from whence they came. Their knowledge came from a learning curve they experienced... to demean another who is early in the learning curve presents a perspective of superiority. My question was not pulled from the air, but was a just concern... you can only learn if you ask the question and that is the core of what this site is about... Thank you for your time today. – petebolduc Mar 01 '14 at 14:54