While the outcome is interesting beware of chart junk: there is less than 15% difference between the methods: your x axis is not at zero so the chart seems to exaggerate the difference. I would guess that since the method would have to "look" for a variable passed by reference that would take more cpu cycles (at the advantage of less memory usage) instead of a variable that is local to the method. If you wanted to print or modify something larger (a 500kb return from a web service for example) the results might change because you may have memory issues affecting the results. I prefer class variables so this experiment validates my methods :). Thanks for doing this test!
While the outcome is interesting beware of chart junk: there is less than 15% difference between the methods: your x axis is not at zero so the chart seems to exaggerate the difference. I would guess that since the method would have to "look" for a variable passed by reference that would take more cpu cycles (at the advantage of less memory usage) instead of a variable that is local to the method. If you wanted to print or modify something larger (a 500kb return from a web service for example) the results might change because you may have memory issues affecting the results. I prefer class variables so this experiment validates my methods :). Thanks for doing this test!