I am curious what the physical "cost" is of calling a function. What really happens to memory when that function is called.
Let's say I've got a complicated loop running in code - and I want to take the "contents" of that loop logic and put it in another C++ function.
If the "variables" and what-not (I've got large arrays and "strings" passed from "managed" code here as well) are all passed by REFERENCE - so no memory is copied for that what is other costs involved?
Is there a GOSUB-like or JSB-like statement in C++ that could help me visually organize this code without incurring the cost of calling functions??
Last edited by szlamany; Sep 1st, 2012 at 11:07 AM.
*** Read the sticky in the DB forum about how to get your question answered quickly!! ***
Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread "Resolved", if the query is solved Microsoft MVP: 2011 - Till Date IMP Links : Acceptable Use Policy, FAQ MyGear:
Sony VGN-FZ27G with a triple boot between (XP+Office 2003+VB6), (VISTA+Office 2007+VS2008) and (Win7+Office 2010+VS2010) || Sony VPCCB-45FN with a Win7+Office 2010+VS2010. VM: (XP+Office 2003+VB6), (VISTA+Office 2007+VS2008), (Win8+Office 2010+VS2012) || Mac Book Pro (10.6.8) with Office 2011
I'm doing loops on 500,000+ byte chunks of memory representing the text of documents. Each character is passed through lots of conditions and also looked at against arrays of rules.
It's that moment of looking at the arrays of rules that I was thinking of removing to a separate function body - passing in whatever is needed by reference. I can see from that article how the stack builds up when that happens.
I was concerned because I was looking at it from the "outside" - where the big loop on the memory chunk is being done. But actually the amount of code running against the array of rules is huge and adding on some stack-framing requirements is most likely inconsequential to the run time.
Bottom line is I can benchmark and time this myself - and I probably should.
*** Read the sticky in the DB forum about how to get your question answered quickly!! ***
Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".