Web Analytics Made Easy -
StatCounter Function efficiency - Return by reference vs value - CodingForum

Announcement

Collapse
No announcement yet.

Function efficiency - Return by reference vs value

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Function efficiency - Return by reference vs value

    Suppose I have two methods of a class, each performing the same function with the same code, the only difference being the way they return a value. One is defined function get_data() {...} and returns a value. The other is defined function &get_data() {...} and returns a reference to the value.

    If the code in these methods fetches a large number of database records and puts them to an associative array, would it be more memory and CPU efficient to pass the results by value or by reference?

    Anyone know a good utility I could use to profile the efficiency of a function?
Working...
X