PHP Performance : Copy vs. Reference

后端 未结 6 1485
南旧
南旧 2021-01-18 02:26

Hey there. Today I wrote a small benchmark script to compare performance of copying variables vs. creating references to them. I was expecting, that creating references to l

6条回答
  •  日久生厌
    2021-01-18 02:50

    in recursiveReference you're calling recursiveCopy... this doesn't make any sense, in this case you're calling recursiveReference just once. correct your code, rund the benchmark again and come back with your new results.

    in addition, i don't think it's useful for a benchmark to do this recursively. a better solution would be to call a function 1000 times in a loop - once with the array directly and one with a reference to that array.

提交回复
热议问题