06.07.2016, 14:30
Quote:
Wow nice.
Ok so I want to ask a question, is the memcpy method to reset an array faster than this? PHP Code:
|
^ and the array size where they meet in performance depends on the CPU!
I did not mention anything about that in the tutorial is because the speed gain is insignificant.
If you do it with a normal loop, say it takes around 1000ms. If you do it with memcpy, you can do it in less than 20ms. If you do the direct array indexing, you may do it in 15ms.
Ask yourself, is the 5ms gain significant compared to the 980ms gain?
Deciding when to use memcpy and when to assign directly would be a unnecessary headache for such an insignificant improvement. Even if assigning directly was 2x faster than memcpy, it would be insignificant. Why? Check the numbers again!
The numbers are guesses but the actual measurements will yield the same results.