<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: time spent in loop in LabVIEW</title>
    <link>https://ni.lithium.com/t5/LabVIEW/time-spent-in-loop/m-p/489504#M234635</link>
    <description>&lt;DIV&gt;&lt;/DIV&gt;
&lt;P&gt;Here is a method I use.&amp;nbsp; I use two tick count(ms) functions one and subtract the difference.&lt;/P&gt;
&lt;P&gt;Brian&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 09 Mar 2007 20:49:50 GMT</pubDate>
    <dc:creator>BrianInTheForest</dc:creator>
    <dc:date>2007-03-09T20:49:50Z</dc:date>
    <item>
      <title>time spent in loop</title>
      <link>https://ni.lithium.com/t5/LabVIEW/time-spent-in-loop/m-p/489490#M234628</link>
      <description>Hi,&lt;BR /&gt;I wanted to know if there is a way to measure how much time (millisecond) is spent in a loop. I have a for loop with 200 iterations (attached as jpg) and would like to know how long the VI stays in the loop. &lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Fri, 09 Mar 2007 20:29:12 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/time-spent-in-loop/m-p/489490#M234628</guid>
      <dc:creator>xradian</dc:creator>
      <dc:date>2007-03-09T20:29:12Z</dc:date>
    </item>
    <item>
      <title>Re: time spent in loop</title>
      <link>https://ni.lithium.com/t5/LabVIEW/time-spent-in-loop/m-p/489499#M234632</link>
      <description>&lt;DIV&gt;&lt;/DIV&gt;
&lt;P&gt;Here is a quick and crude way to do it&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Mar 2007 20:43:48 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/time-spent-in-loop/m-p/489499#M234632</guid>
      <dc:creator>Beaton</dc:creator>
      <dc:date>2007-03-09T20:43:48Z</dc:date>
    </item>
    <item>
      <title>Re: time spent in loop</title>
      <link>https://ni.lithium.com/t5/LabVIEW/time-spent-in-loop/m-p/489504#M234635</link>
      <description>&lt;DIV&gt;&lt;/DIV&gt;
&lt;P&gt;Here is a method I use.&amp;nbsp; I use two tick count(ms) functions one and subtract the difference.&lt;/P&gt;
&lt;P&gt;Brian&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Mar 2007 20:49:50 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/time-spent-in-loop/m-p/489504#M234635</guid>
      <dc:creator>BrianInTheForest</dc:creator>
      <dc:date>2007-03-09T20:49:50Z</dc:date>
    </item>
    <item>
      <title>Re: time spent in loop</title>
      <link>https://ni.lithium.com/t5/LabVIEW/time-spent-in-loop/m-p/489506#M234637</link>
      <description>&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;
&lt;P&gt;You can place the elapsed time express vi in the loop, make sure to wire the Reset and Auto Resest Inputs to false.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;IMG src="http://forums.ni.com/attachments/ni/170/234637/1/time%20in%20loop.PNG" /&gt;&lt;/P&gt;&lt;P&gt;Message Edited by AndrewAlford on &lt;SPAN class="date_text"&gt;03-09-2007&lt;/SPAN&gt; &lt;SPAN class="time_text"&gt;01:51 PM&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Mar 2007 20:50:58 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/time-spent-in-loop/m-p/489506#M234637</guid>
      <dc:creator>AndrewAlford</dc:creator>
      <dc:date>2007-03-09T20:50:58Z</dc:date>
    </item>
    <item>
      <title>Re: time spent in loop</title>
      <link>https://ni.lithium.com/t5/LabVIEW/time-spent-in-loop/m-p/489574#M234676</link>
      <description>thanks for all the replies. I used the last method suggested as it was the easiest.&lt;BR /&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Fri, 09 Mar 2007 23:00:08 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/time-spent-in-loop/m-p/489574#M234676</guid>
      <dc:creator>xradian</dc:creator>
      <dc:date>2007-03-09T23:00:08Z</dc:date>
    </item>
    <item>
      <title>Re: time spent in loop</title>
      <link>https://ni.lithium.com/t5/LabVIEW/time-spent-in-loop/m-p/489848#M234828</link>
      <description>&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;I would not add anything into my loop that might add to the total process time.&amp;nbsp;&amp;nbsp; The easiest method to implement might not be the best for performance.&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;Brian&lt;/DIV&gt;&lt;P&gt;Message Edited by brianlachlan on &lt;SPAN class="date_text"&gt;03-11-2007&lt;/SPAN&gt; &lt;SPAN class="time_text"&gt;05:42 PM&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 11 Mar 2007 21:41:43 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/time-spent-in-loop/m-p/489848#M234828</guid>
      <dc:creator>BrianInTheForest</dc:creator>
      <dc:date>2007-03-11T21:41:43Z</dc:date>
    </item>
    <item>
      <title>Re: time spent in loop</title>
      <link>https://ni.lithium.com/t5/LabVIEW/time-spent-in-loop/m-p/489854#M234830</link>
      <description>&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;Brian,&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;For me it is still too expensive to take the tick count at &lt;STRONG&gt;every iteration&lt;/STRONG&gt;, even though you only need the last value. If you take the second tick count only after the loop has finished, the VI shown is yet another &lt;STRONG&gt;8x faster&lt;/STRONG&gt;.&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;(Note that I cranked it up to 1000000 iterations).. Tick "inside": 64ms, as shown: 8ms. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&lt;IMG src="http://forums.ni.com/attachments/ni/170/234830/1/EvenFaster.png" /&gt;&lt;/DIV&gt;
&lt;DIV&gt;Yes, sometimes a sequence structrure us useful! &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;(I also wired the array across the sequence to make sure the indicator update happens &lt;U&gt;after&lt;/U&gt; the second tick probe.)&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;P&gt;Message Edited by altenbach on &lt;SPAN class="date_text"&gt;03-11-2007&lt;/SPAN&gt; &lt;SPAN class="time_text"&gt;03:11 PM&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 11 Mar 2007 22:08:43 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/time-spent-in-loop/m-p/489854#M234830</guid>
      <dc:creator>altenbach</dc:creator>
      <dc:date>2007-03-11T22:08:43Z</dc:date>
    </item>
    <item>
      <title>Re: time spent in loop</title>
      <link>https://ni.lithium.com/t5/LabVIEW/time-spent-in-loop/m-p/489857#M234833</link>
      <description>&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;Christian,&lt;/DIV&gt;
&lt;DIV&gt;Thanks for the advice, would not have thought the tick count added so much.&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;Brian&lt;/DIV&gt;</description>
      <pubDate>Sun, 11 Mar 2007 22:36:17 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/time-spent-in-loop/m-p/489857#M234833</guid>
      <dc:creator>BrianInTheForest</dc:creator>
      <dc:date>2007-03-11T22:36:17Z</dc:date>
    </item>
    <item>
      <title>Re: time spent in loop</title>
      <link>https://ni.lithium.com/t5/LabVIEW/time-spent-in-loop/m-p/489940#M234859</link>
      <description>&lt;DIV&gt;Well, it's actually not adding not that much per iteration (56ms/1000000 iterations, or about 56ns). It will only make a real difference for very fast loops. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;I agree that the express VI is a drag, though. &lt;span class="lia-unicode-emoji" title=":face_with_open_mouth:"&gt;😮&lt;/span&gt;&lt;/DIV&gt;</description>
      <pubDate>Mon, 12 Mar 2007 08:33:08 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/time-spent-in-loop/m-p/489940#M234859</guid>
      <dc:creator>altenbach</dc:creator>
      <dc:date>2007-03-12T08:33:08Z</dc:date>
    </item>
    <item>
      <title>Re: time spent in loop</title>
      <link>https://ni.lithium.com/t5/LabVIEW/time-spent-in-loop/m-p/490209#M234974</link>
      <description>when i use the tickcount method it takes a longer time for my loop!?&lt;BR /&gt;When I used the time elapsed method 10 iterations took 0.25 sec but with the tickcount method I'm getting 1392ms.&lt;BR /&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Mon, 12 Mar 2007 16:37:30 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/time-spent-in-loop/m-p/490209#M234974</guid>
      <dc:creator>xradian</dc:creator>
      <dc:date>2007-03-12T16:37:30Z</dc:date>
    </item>
    <item>
      <title>Re: time spent in loop</title>
      <link>https://ni.lithium.com/t5/LabVIEW/time-spent-in-loop/m-p/490238#M234989</link>
      <description>&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;
&lt;P&gt;I think your loop time is entirely determined by the hardware interaction, so the the timing is insignificantly fast in both cases.&lt;/P&gt;
&lt;P&gt;However you current timing code is &lt;STRONG&gt;heavily flawed&lt;/STRONG&gt; because it is impossible to tell at what time the first tick count is taken (No data dependency!). Most likely, the first tick count executes BEFORE (or in parallel to)&amp;nbsp;the&amp;nbsp;"OPEN1" and "OPEN2" nodes, so you are actually including their times in the measurnements. Remember, LabVIEW does not execute left-to-right. Any node that does not need to wait for inputs is ready to execute immediately.&lt;/P&gt;
&lt;P&gt;You need to place the first tick count inside a sequence frame too to ensure it executes right before the FOR loop. For exact timings use a 3-frame sequence as in the image.&lt;/P&gt;
&lt;P align="center"&gt;&lt;IMG src="http://forums.ni.com/attachments/ni/170/234989/1/PreciseLoopTime.png" /&gt;&lt;/P&gt;
&lt;P&gt;Make sure that everything that should not be timed is before or after the sequence. Also make sure there is no code that can run parallel to the sequence.&lt;/P&gt;&lt;P&gt;Message Edited by altenbach on &lt;SPAN class="date_text"&gt;03-12-2007&lt;/SPAN&gt; &lt;SPAN class="time_text"&gt;10:01 AM&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 12 Mar 2007 17:00:58 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/time-spent-in-loop/m-p/490238#M234989</guid>
      <dc:creator>altenbach</dc:creator>
      <dc:date>2007-03-12T17:00:58Z</dc:date>
    </item>
  </channel>
</rss>

