PHP Objects vs Arrays — Performance comparison while iterating

前端 未结 10 1801
青春惊慌失措
青春惊慌失措 2020-11-27 11:25

I have a huge amount of PHP objects for a neural network for which I have to iterate over and perform some maths on. I was wondering if I would be better off using an associ

10条回答
  •  無奈伤痛
    2020-11-27 11:59

    You can always check the PHP-source code for micro-performance-features like that.

    But at a first glance, no doing ['value'] will not be faster because PHP needs to do a Lookup on where to find ['value'] even thougn a hashtable lookup should be O(1), that's not guaranteed. There's more overhead when you use Text-index.

    If the object only contains 1 variables that you need to access which is value, there's more overhead in using an object.

提交回复
热议问题