<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://pickwiki.org/index.php?action=history&amp;feed=atom&amp;title=RemovePerformance</id>
	<title>RemovePerformance - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://pickwiki.org/index.php?action=history&amp;feed=atom&amp;title=RemovePerformance"/>
	<link rel="alternate" type="text/html" href="https://pickwiki.org/index.php?title=RemovePerformance&amp;action=history"/>
	<updated>2026-04-28T23:39:02Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.0</generator>
	<entry>
		<id>https://pickwiki.org/index.php?title=RemovePerformance&amp;diff=2624&amp;oldid=prev</id>
		<title>IanMcGowan at 05:17, 22 April 2019</title>
		<link rel="alternate" type="text/html" href="https://pickwiki.org/index.php?title=RemovePerformance&amp;diff=2624&amp;oldid=prev"/>
		<updated>2019-04-22T05:17:59Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 05:17, 22 April 2019&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l51&quot;&gt;Line 51:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 51:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/nowiki&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/nowiki&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Which leads to a significant speedup&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;:&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Which leads to a significant speedup&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;, even without taking into account caching, the REMOVE command is still much faster.&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  Read in:11ms&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  Read in:11ms&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>IanMcGowan</name></author>
	</entry>
	<entry>
		<id>https://pickwiki.org/index.php?title=RemovePerformance&amp;diff=2623&amp;oldid=prev</id>
		<title>IanMcGowan: Created page with &quot;== Improving performance when looping over a dynamic array ==  It&#039;s a frequent requirement to loop over a large dynamic array.  E.g.   &lt;nowiki&gt; A=&lt;get a large array from somew...&quot;</title>
		<link rel="alternate" type="text/html" href="https://pickwiki.org/index.php?title=RemovePerformance&amp;diff=2623&amp;oldid=prev"/>
		<updated>2019-04-22T03:55:08Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;== Improving performance when looping over a dynamic array ==  It&amp;#039;s a frequent requirement to loop over a large dynamic array.  E.g.   &amp;lt;nowiki&amp;gt; A=&amp;lt;get a large array from somew...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;== Improving performance when looping over a dynamic array ==&lt;br /&gt;
&lt;br /&gt;
It&amp;#039;s a frequent requirement to loop over a large dynamic array.  E.g.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
A=&amp;lt;get a large array from somewhere&amp;gt;&lt;br /&gt;
FOR F=1 TO DCOUNT(A,@AM)&lt;br /&gt;
  ..do stuff with A&lt;br /&gt;
NEXT F&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Some flavors of Pick Basic will optimize that DCOUNT so it&amp;#039;s not done every time, but some will not.  So to be safe, it&amp;#039;s better to move that out of the loop:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
A=&amp;lt;get a large array from somewhere&amp;gt;&lt;br /&gt;
MAX.A=DCOUNT(A,@AM)&lt;br /&gt;
FOR F=1 TO MAX.A&lt;br /&gt;
  ..do stuff with A&lt;br /&gt;
NEXT F&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
But now you still have to deal with the &amp;quot;do stuff with A&amp;quot; part.  This will probably involve extracting the current MV for A from the loop.  I.e. extracting A&amp;lt;F&amp;gt;.  The problem with this is the system will scan from the start of the array to the value you want.  If the array is very large, this may take a significant amount of time.  One way around this is to use the REMOVE statement, which &amp;quot;remembers&amp;quot; where in the array the last position was found, and can go right there on the next call.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
OPEN &amp;#039;TMP&amp;#039; TO TMP.F ELSE STOP 201,&amp;#039;TMP&amp;#039;&lt;br /&gt;
T=SYSTEM(12)&lt;br /&gt;
READ A FROM TMP.F, &amp;#039;test3.txt&amp;#039; ELSE STOP &amp;quot;CANNOT READ TEST.FILE&amp;quot;&lt;br /&gt;
CRT &amp;#039;Read in:&amp;#039;:SYSTEM(12)-T:&amp;#039;ms&amp;#039;&lt;br /&gt;
*&lt;br /&gt;
T=SYSTEM(12)&lt;br /&gt;
MAX.A=DCOUNT(A,@AM)&lt;br /&gt;
CRT MAX.A:&amp;#039; count in &amp;#039;:SYSTEM(12)-T:&amp;#039;ms&amp;#039;&lt;br /&gt;
*&lt;br /&gt;
L=0&lt;br /&gt;
T=SYSTEM(12)&lt;br /&gt;
FOR F=1 TO MAX.A&lt;br /&gt;
  L+=LEN(A&amp;lt;F&amp;gt;)&lt;br /&gt;
NEXT F&lt;br /&gt;
CRT &amp;#039;FOR Loop:&amp;#039;:SYSTEM(12)-T:&amp;#039;ms&amp;#039;&lt;br /&gt;
CRT L&lt;br /&gt;
*&lt;br /&gt;
L=0&lt;br /&gt;
T=SYSTEM(12)&lt;br /&gt;
LOOP&lt;br /&gt;
  REMOVE X FROM A SETTING MORE&lt;br /&gt;
  L+=LEN(X)&lt;br /&gt;
WHILE MORE DO&lt;br /&gt;
REPEAT&lt;br /&gt;
CRT &amp;#039;LOOP/REMOVE:&amp;#039;:SYSTEM(12)-T:&amp;#039;ms&amp;#039;&lt;br /&gt;
CRT L&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Which leads to a significant speedup:&lt;br /&gt;
&lt;br /&gt;
 Read in:11ms&lt;br /&gt;
 100000 count in 2ms&lt;br /&gt;
 For loop:&amp;#039;&amp;#039;&amp;#039;71504ms&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
 9048987&lt;br /&gt;
 LOOP/REMOVE:&amp;#039;&amp;#039;&amp;#039;35ms&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
 9048987&lt;/div&gt;</summary>
		<author><name>IanMcGowan</name></author>
	</entry>
</feed>