<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	
	>
<channel>
	<title>Comments on: SPL Iterators against the performance</title>
	<atom:link href="http://piotrpasich.com/spl-iterators-against-the-performance/feed/" rel="self" type="application/rss+xml" />
	<link>http://piotrpasich.com/spl-iterators-against-the-performance/</link>
	<description>PHP, Symfony, Design Patterns</description>
	<lastBuildDate>Fri, 08 Sep 2023 13:45:00 +0000</lastBuildDate>
		<sy:updatePeriod>hourly</sy:updatePeriod>
		<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=4.0.38</generator>
	<item>
		<title>By: Piotr Pasich</title>
		<link>http://piotrpasich.com/spl-iterators-against-the-performance/#comment-89</link>
		<dc:creator><![CDATA[Piotr Pasich]]></dc:creator>
		<pubDate>Tue, 27 Jan 2015 07:02:00 +0000</pubDate>
		<guid isPermaLink="false">http://piotrpasich.com/?p=2444#comment-89</guid>
		<description><![CDATA[Hi Adrian, 

nice answer. I can tell you what happen if you run 1,000,000 iterations based on loop - this will take about 72 MB in 1.13 s.

I have investigated the memory usage too, but the differences was too small to talk about this and was caused by using objects against simple arrays. Why the SPL Iterator&#039;s code shows you so low memory usage? Because the memory is freed just after the last foreach. It works in the same way as in the case where you put all the code from http://codepad.viper-7.com/k68YS6 into function like this: https://gist.github.com/piotrpasich/857cd0e4a0988e11a5f4 . At the result, the memory usage is  0.58746337890625 KB. 

So, the place where you measure the memory matters. 

Thank you for the comment,
Piotr]]></description>
		<content:encoded><![CDATA[<p>Hi Adrian, </p>
<p>nice answer. I can tell you what happen if you run 1,000,000 iterations based on loop &#8211; this will take about 72 MB in 1.13 s.</p>
<p>I have investigated the memory usage too, but the differences was too small to talk about this and was caused by using objects against simple arrays. Why the SPL Iterator&#8217;s code shows you so low memory usage? Because the memory is freed just after the last foreach. It works in the same way as in the case where you put all the code from <a href="http://codepad.viper-7.com/k68YS6" rel="nofollow">http://codepad.viper-7.com/k68YS6</a> into function like this: <a href="https://gist.github.com/piotrpasich/857cd0e4a0988e11a5f4" rel="nofollow">https://gist.github.com/piotrpasich/857cd0e4a0988e11a5f4</a> . At the result, the memory usage is  0.58746337890625 KB. </p>
<p>So, the place where you measure the memory matters. </p>
<p>Thank you for the comment,<br />
Piotr</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Adrian Cardenas</title>
		<link>http://piotrpasich.com/spl-iterators-against-the-performance/#comment-88</link>
		<dc:creator><![CDATA[Adrian Cardenas]]></dc:creator>
		<pubDate>Mon, 26 Jan 2015 23:02:00 +0000</pubDate>
		<guid isPermaLink="false">http://piotrpasich.com/?p=2444#comment-88</guid>
		<description><![CDATA[Nice over view of how to use iterators &amp; their benefits.

However, you skipped over probably the best reason to use iterators, which is the efficiencies gained in memory. 

I tested your code (with some slight modifications for running online vs the command line) on PHP 5.6.1 &amp; added measurements for memory usage.

Code using loops:
100,000 iterations - http://codepad.viper-7.com/k68YS6
Duration: 0.095134973526001
Memory: 0.296875 KB

1,000,000 iterations - The script ran out of memory in the REPL environment while generating the first array

Code using Iterators
100,000 iterations - http://codepad.viper-7.com/ptauX3
Duration: 0.21263003349304
Memory: 2.15625 KB

1,000,000 iterations - http://codepad.viper-7.com/m3cNIy
Duration: 2.1547520160675
Memory: 2.15625 KB

As you can see, you see the same marked increase in time from using loops to using iterators for the 100k iteration test. Memory usage is also more. However, in the iterators test going increasing the iterations by an order of magnitude increased the duration by an order of magnitude as well, but the memory usage remained constant. Increasing another order of magnitude would increase the duration as well, but memory usage wouldn&#039;t go up much more than the 2.2 KB being used by the script.]]></description>
		<content:encoded><![CDATA[<p>Nice over view of how to use iterators &amp; their benefits.</p>
<p>However, you skipped over probably the best reason to use iterators, which is the efficiencies gained in memory. </p>
<p>I tested your code (with some slight modifications for running online vs the command line) on PHP 5.6.1 &amp; added measurements for memory usage.</p>
<p>Code using loops:<br />
100,000 iterations &#8211; <a href="http://codepad.viper-7.com/k68YS6" rel="nofollow">http://codepad.viper-7.com/k68YS6</a><br />
Duration: 0.095134973526001<br />
Memory: 0.296875 KB</p>
<p>1,000,000 iterations &#8211; The script ran out of memory in the REPL environment while generating the first array</p>
<p>Code using Iterators<br />
100,000 iterations &#8211; <a href="http://codepad.viper-7.com/ptauX3" rel="nofollow">http://codepad.viper-7.com/ptauX3</a><br />
Duration: 0.21263003349304<br />
Memory: 2.15625 KB</p>
<p>1,000,000 iterations &#8211; <a href="http://codepad.viper-7.com/m3cNIy" rel="nofollow">http://codepad.viper-7.com/m3cNIy</a><br />
Duration: 2.1547520160675<br />
Memory: 2.15625 KB</p>
<p>As you can see, you see the same marked increase in time from using loops to using iterators for the 100k iteration test. Memory usage is also more. However, in the iterators test going increasing the iterations by an order of magnitude increased the duration by an order of magnitude as well, but the memory usage remained constant. Increasing another order of magnitude would increase the duration as well, but memory usage wouldn&#8217;t go up much more than the 2.2 KB being used by the script.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Angelina</title>
		<link>http://piotrpasich.com/spl-iterators-against-the-performance/#comment-86</link>
		<dc:creator><![CDATA[Angelina]]></dc:creator>
		<pubDate>Fri, 23 Jan 2015 11:02:00 +0000</pubDate>
		<guid isPermaLink="false">http://piotrpasich.com/?p=2444#comment-86</guid>
		<description><![CDATA[Shenzhen Sunper Opto Co.,ltd is a professional led high bay light manufacturer with ten years&#039; experience. We use Cree led and Meanwell driver, with the strength of top quality and competitive price, and with UL DLc CE RoHs Certificates,our products have a good reputation in North America and Europe.


Products Feature:
1.use Cree led and Meanwell driver specialize designed in led high bay light
2.3-5 years warranty
3.The appearance treatment in Black
    a.Black demontrates elegance, fashion and distinction.
    b.Black radiator with good heat dissipation, higher heat dissipation efficiency than others,reduce the lumens depreciation of the lamp, extend the 
life-span of lamp.
4.The structure of lamp adopts round layered design, manifesting the uniform beauty of lamps.


if you need more, please feel free to contact me(angelina@sunper.net) or click our website for details:http://www.sunper.net/]]></description>
		<content:encoded><![CDATA[<p>Shenzhen Sunper Opto Co.,ltd is a professional led high bay light manufacturer with ten years&#8217; experience. We use Cree led and Meanwell driver, with the strength of top quality and competitive price, and with UL DLc CE RoHs Certificates,our products have a good reputation in North America and Europe.</p>
<p>Products Feature:<br />
1.use Cree led and Meanwell driver specialize designed in led high bay light<br />
2.3-5 years warranty<br />
3.The appearance treatment in Black<br />
    a.Black demontrates elegance, fashion and distinction.<br />
    b.Black radiator with good heat dissipation, higher heat dissipation efficiency than others,reduce the lumens depreciation of the lamp, extend the<br />
life-span of lamp.<br />
4.The structure of lamp adopts round layered design, manifesting the uniform beauty of lamps.</p>
<p>if you need more, please feel free to contact me(angelina@sunper.net) or click our website for details:<a href="http://www.sunper.net/" rel="nofollow">http://www.sunper.net/</a></p>
]]></content:encoded>
	</item>
</channel>
</rss>
