Check PHP Code Performance and stdClass using InfiniteIterator

Following code is written using stdClass and PHP iterator “InfiniteIterator”

And this code wrap between microtime() function to checkout the time consumed for this operation from start to end. stdClass class object hold three dynamic variable which we assign at the run time, then we pass the stdClass object to Itrerator “ArrayIterator” and then to “InfiniteIterator”. using foreach loop we are printing 1400000 values by assigning the object of InfiniteIterator to LimitIterator. if we will not use “LimitIterator”, loop will not end.

stdClass is php’s generic empty class, It is useful for anonymous objects, dynamic properties, etc.

When you run this code, your browser will stop working for few second until LimitIterator loop will end. at then end of these all printed values you will time consumed by this code. you can change parameter for LimitIterator to check variable amount of printed values and check the time.