<?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: microsecond tick count in LabVIEW</title>
    <link>https://ni.lithium.com/t5/LabVIEW/microsecond-tick-count/m-p/904826#M407828</link>
    <description>&lt;P&gt;Here is an 8.0.1 version of the code (Windows only!).&amp;nbsp; It includes VIs to query the frequency of the counter, the tick count, and calculate the interval from two tick counts.&amp;nbsp; It will only work on processors which have a high resolution timer (I think this was introduced with the Pentium Pro, but it has been awhile and I could be wrong).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Note that due to the multi-tasking nature of Windows, you should probably take a large set of measurements and then take your minimum.&amp;nbsp; Be sure to take into account your infrastructure time (loop time, VI call time, etc.).&amp;nbsp; It can be challenging, but it is also fun to figure it out.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Let us know if you need more info. &lt;/P&gt;</description>
    <pubDate>Mon, 11 May 2009 13:55:11 GMT</pubDate>
    <dc:creator>DFGray</dc:creator>
    <dc:date>2009-05-11T13:55:11Z</dc:date>
    <item>
      <title>microsecond tick count</title>
      <link>https://ni.lithium.com/t5/LabVIEW/microsecond-tick-count/m-p/396104#M197442</link>
      <description>&lt;DIV&gt;To do some fast and dirty performance analysis, I was wondering if I could get less than ms resolution from anything in LabView.&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;I found this post&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&lt;A href="http://forums.ni.com/ni/board/message?board.id=170&amp;amp;message.id=165500&amp;amp;query.id=205509#M165500" target="_blank"&gt;http://forums.ni.com/ni/board/message?board.id=170&amp;amp;message.id=165500&amp;amp;query.id=205509#M165500&lt;/A&gt;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;Which seems to ask the same question, but the answer seems more like a CVI answer than LabView.&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;Can you access the Query... API from LabView?&lt;/DIV&gt;
&lt;DIV&gt;If so, can someone please tell me how?&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;Thanks&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;</description>
      <pubDate>Tue, 25 Jul 2006 18:42:07 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/microsecond-tick-count/m-p/396104#M197442</guid>
      <dc:creator>jspaarg</dc:creator>
      <dc:date>2006-07-25T18:42:07Z</dc:date>
    </item>
    <item>
      <title>Re: microsecond tick count</title>
      <link>https://ni.lithium.com/t5/LabVIEW/microsecond-tick-count/m-p/396108#M197445</link>
      <description>&lt;DIV&gt;&lt;/DIV&gt;
&lt;P&gt;&lt;FONT size="2"&gt;In addition to the answer you linked, there's also a LabVIEW-based&amp;nbsp;example that uses the RDTSC (ReaD TimeStamp Counter) instruction to query a counter that increments at CPU freq (or thereabouts, I don't know the raw gory details down at that low level).&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="2"&gt;It was intended for use under Pentium-based RT systems, but I recall using it under Windows as well.&amp;nbsp; Here's a &lt;A href="http://sine.ni.com/apps/utf8/niepd_web_display.display_epd4?p_guid=B45EACE3E68356A4E034080020E74861" target="_blank"&gt;link&lt;/A&gt;.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="2"&gt;Just keep in mind that the timing uncertainty for a chain of function calls under Windows may be orders of magnitude greater than the actual CPU usage time.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="2"&gt;When I'm checking performance under Windows, I usually look for some type of average time over maybe 10000+ calls, depending on the thingy I'm benchmarking.&amp;nbsp; Also note that sometimes performance during a benchmark can be significantly better than it is in normal use.&amp;nbsp; The tight looping may keep a lot of things in a local cache and require many fewer than normal wait states for memory access.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="2"&gt;Good luck!&amp;nbsp; Despite the quirks and difficulties of performing benchmarks, it's still good to take your best shot at it.&amp;nbsp; &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="2"&gt;-Kevin P.&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 25 Jul 2006 18:53:13 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/microsecond-tick-count/m-p/396108#M197445</guid>
      <dc:creator>Kevin_Price</dc:creator>
      <dc:date>2006-07-25T18:53:13Z</dc:date>
    </item>
    <item>
      <title>Re: microsecond tick count</title>
      <link>https://ni.lithium.com/t5/LabVIEW/microsecond-tick-count/m-p/396113#M197448</link>
      <description>&lt;DIV&gt;&lt;/DIV&gt;
&lt;P&gt;Thanks a lot.&amp;nbsp; I will give this a try.&lt;/P&gt;
&lt;P&gt;Spending most of my adult life in embedded, I am used to being able to get statistically significant information with just a few samples (assuming you know the architecture).&amp;nbsp; I realize that just won't happen with a PC, but I would like to get a general idea what I'm up against.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks again.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 25 Jul 2006 18:58:59 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/microsecond-tick-count/m-p/396113#M197448</guid>
      <dc:creator>jspaarg</dc:creator>
      <dc:date>2006-07-25T18:58:59Z</dc:date>
    </item>
    <item>
      <title>Re: microsecond tick count</title>
      <link>https://ni.lithium.com/t5/LabVIEW/microsecond-tick-count/m-p/396154#M197471</link>
      <description>&lt;DIV&gt;Here's a little LLB I wrote for accessing QueryPerformanceCounter. Basically you just have to use the time output from the HighResTimer.vi. You may also have to relink the DLL calls to kernel.dll. Note&amp;nbsp;this only works on a windows system. &amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;If you need to tweak it. I wrote the code originally in LV7, which is why I'm internally using a pair of&amp;nbsp;int32s instead of a single int64. &lt;/DIV&gt;</description>
      <pubDate>Tue, 25 Jul 2006 20:39:07 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/microsecond-tick-count/m-p/396154#M197471</guid>
      <dc:creator>Matt_W1</dc:creator>
      <dc:date>2006-07-25T20:39:07Z</dc:date>
    </item>
    <item>
      <title>Re: microsecond tick count</title>
      <link>https://ni.lithium.com/t5/LabVIEW/microsecond-tick-count/m-p/396155#M197472</link>
      <description>&lt;DIV&gt;&lt;/DIV&gt;
&lt;P&gt;Thanks a bunch.&lt;/P&gt;
&lt;P&gt;I will take a look at this later.&lt;/P&gt;
&lt;P&gt;LabView 7 is perfect as I am using 7.1&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 25 Jul 2006 20:41:41 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/microsecond-tick-count/m-p/396155#M197472</guid>
      <dc:creator>jspaarg</dc:creator>
      <dc:date>2006-07-25T20:41:41Z</dc:date>
    </item>
    <item>
      <title>Re: microsecond tick count</title>
      <link>https://ni.lithium.com/t5/LabVIEW/microsecond-tick-count/m-p/396157#M197473</link>
      <description>&lt;DIV&gt;I updated it to use int64, so it's just one VI now&lt;/DIV&gt;</description>
      <pubDate>Tue, 25 Jul 2006 20:45:52 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/microsecond-tick-count/m-p/396157#M197473</guid>
      <dc:creator>Matt_W1</dc:creator>
      <dc:date>2006-07-25T20:45:52Z</dc:date>
    </item>
    <item>
      <title>Re: microsecond tick count</title>
      <link>https://ni.lithium.com/t5/LabVIEW/microsecond-tick-count/m-p/396162#M197476</link>
      <description>&lt;DIV&gt;&lt;/DIV&gt;
&lt;P&gt;I found an old version compiled under 7.1&lt;/P&gt;
&lt;P&gt;Hopefully this one should work for you&lt;/P&gt;</description>
      <pubDate>Tue, 25 Jul 2006 21:02:47 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/microsecond-tick-count/m-p/396162#M197476</guid>
      <dc:creator>Matt_W1</dc:creator>
      <dc:date>2006-07-25T21:02:47Z</dc:date>
    </item>
    <item>
      <title>Re: microsecond tick count</title>
      <link>https://ni.lithium.com/t5/LabVIEW/microsecond-tick-count/m-p/524801#M248732</link>
      <description>&lt;DIV&gt;&lt;/DIV&gt;
&lt;P&gt;Hi Matt,&lt;/P&gt;
&lt;P&gt;I believe you made an error in your code to join two 32-bit numbers.&amp;nbsp; The high part should be multiplied by 2^32 = 4,294,967,296 (an even number), not 4,294,967,295.&amp;nbsp; Unless you are trying to compensate for the code processing time to do the calculation.&lt;/P&gt;
&lt;P&gt;Regards, Jay&lt;/P&gt;</description>
      <pubDate>Tue, 22 May 2007 16:23:23 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/microsecond-tick-count/m-p/524801#M248732</guid>
      <dc:creator>LV_J</dc:creator>
      <dc:date>2007-05-22T16:23:23Z</dc:date>
    </item>
    <item>
      <title>Re: microsecond tick count</title>
      <link>https://ni.lithium.com/t5/LabVIEW/microsecond-tick-count/m-p/524928#M248782</link>
      <description>You're right that is wrong, I would post corrected code but for some reason QPC is only accurate to one second on my machine (I don't have time to figure out why, although that is really weird. I have unusual windows setup though, so it's likely just me), so I can't really test it. The 8.0 code that uses 64bit ints isn't affected.&amp;nbsp; As a warning, QPC doesn't work right on certain old chipsets, and on some multicore CPUS (The AMD hotfix and /pmtimer in boot.ini usually straightens out the dual cores). But for quick and dirty performance analysis on a development machine it should be good.&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Tue, 22 May 2007 20:03:33 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/microsecond-tick-count/m-p/524928#M248782</guid>
      <dc:creator>Matt_W1</dc:creator>
      <dc:date>2007-05-22T20:03:33Z</dc:date>
    </item>
    <item>
      <title>Re: microsecond tick count</title>
      <link>https://ni.lithium.com/t5/LabVIEW/microsecond-tick-count/m-p/574372#M269328</link>
      <description>I can also only get the VI to be accurate to 1s. I've tried it on multiple PCs (AMD and Intel chips) but no change. Anyone know why?&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Mon, 03 Sep 2007 14:25:01 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/microsecond-tick-count/m-p/574372#M269328</guid>
      <dc:creator>eoinbutler</dc:creator>
      <dc:date>2007-09-03T14:25:01Z</dc:date>
    </item>
    <item>
      <title>Re: microsecond tick count</title>
      <link>https://ni.lithium.com/t5/LabVIEW/microsecond-tick-count/m-p/574501#M269397</link>
      <description>&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;
&lt;P&gt;I can easily measure loop times in the low microseconds after doing some modifications.&lt;/P&gt;
&lt;P&gt;Try a loop time of 0, 1, 2, or 3 ms for example. You'll also notice that on many modern processors, a 1ms will turn into a 2ms wait.&lt;/P&gt;
&lt;P&gt;I&amp;nbsp;am still not entire sure about the U64 division. Maybe it is OK.&lt;/P&gt;
&lt;P&gt;See attached example (LabVIEW 8.2)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Message Edited by altenbach on &lt;SPAN class="date_text"&gt;09-03-2007&lt;/SPAN&gt; &lt;SPAN class="time_text"&gt;01:56 PM&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 03 Sep 2007 20:53:14 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/microsecond-tick-count/m-p/574501#M269397</guid>
      <dc:creator>altenbach</dc:creator>
      <dc:date>2007-09-03T20:53:14Z</dc:date>
    </item>
    <item>
      <title>Re: microsecond tick count</title>
      <link>https://ni.lithium.com/t5/LabVIEW/microsecond-tick-count/m-p/687631#M315472</link>
      <description>The file is saved on v8.2. Can you please save it as v8.0?&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 10 Apr 2008 22:51:30 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/microsecond-tick-count/m-p/687631#M315472</guid>
      <dc:creator>YHAnis</dc:creator>
      <dc:date>2008-04-10T22:51:30Z</dc:date>
    </item>
    <item>
      <title>Re: microsecond tick count</title>
      <link>https://ni.lithium.com/t5/LabVIEW/microsecond-tick-count/m-p/904501#M407717</link>
      <description>&lt;P&gt;Althought this thread is just short of 2 years old, I have some questions regarding sub millisecond timer work, such as in the HighResTimer.vi that was posted here. &lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;One of the comments in this thread indicates that on some chipsets and multicore systems, the QueryPerformanceCounter does not necessarily work correctly.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;On the MSDN boards for QPC, I found this remark:&lt;/P&gt;&lt;P&gt;"On a multiprocessor computer, it should not matter which processor is
called. However, you can get different results on different processors
due to bugs in the basic input/output system (BIOS) or the hardware
abstraction layer (HAL). To specify processor affinity for a thread,
use the SetThreadAffinityMask function."&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So, is the problem of QPC in Labview only that it may poll the Counter from a different thread? Is there a way to circumvent this, with the SetThreadAffinityMask function to only call the HighResTimer.vi using a specific thread?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Other things I've read about this:&lt;/P&gt;&lt;P&gt;"If there's heavy bus traffic, on many, common chip sets, even very new ones, this timer may suddenly jump between one and four seconds forward in time (boo!). I believe there is some internal race WRT this counter being 64 bits, but kept in two separate 32-bit registers, but don't hold me to that." &lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;Is all of this true?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I want to do: monitor parallel port and determine the time between consecutive pulses. The pulses are spaced approximately 25ms apart, so using the ms tick counter, even one ms off and I have a 4% change... I don't want much more resolution, really 1-2% margin of error is okay. Will the QPC be alright for my purposes? &lt;/P&gt;&lt;BR /&gt;&lt;P&gt;Or is my misunderstanding of this all skewed?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks &lt;/P&gt;&lt;P&gt;Brian &lt;/P&gt;</description>
      <pubDate>Sun, 10 May 2009 20:57:50 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/microsecond-tick-count/m-p/904501#M407717</guid>
      <dc:creator>sensorimotor_nsc</dc:creator>
      <dc:date>2009-05-10T20:57:50Z</dc:date>
    </item>
    <item>
      <title>Re: microsecond tick count</title>
      <link>https://ni.lithium.com/t5/LabVIEW/microsecond-tick-count/m-p/904826#M407828</link>
      <description>&lt;P&gt;Here is an 8.0.1 version of the code (Windows only!).&amp;nbsp; It includes VIs to query the frequency of the counter, the tick count, and calculate the interval from two tick counts.&amp;nbsp; It will only work on processors which have a high resolution timer (I think this was introduced with the Pentium Pro, but it has been awhile and I could be wrong).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Note that due to the multi-tasking nature of Windows, you should probably take a large set of measurements and then take your minimum.&amp;nbsp; Be sure to take into account your infrastructure time (loop time, VI call time, etc.).&amp;nbsp; It can be challenging, but it is also fun to figure it out.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Let us know if you need more info. &lt;/P&gt;</description>
      <pubDate>Mon, 11 May 2009 13:55:11 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/microsecond-tick-count/m-p/904826#M407828</guid>
      <dc:creator>DFGray</dc:creator>
      <dc:date>2009-05-11T13:55:11Z</dc:date>
    </item>
    <item>
      <title>Re: microsecond tick count</title>
      <link>https://ni.lithium.com/t5/LabVIEW/microsecond-tick-count/m-p/904847#M407835</link>
      <description>&lt;P&gt;FYI:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If using LV Real-Time is an option then sub-microsecond measurements can be performed by uisng hardware clocked counters. Using NI stuff I used an 80 MHz clock to meassure node to node SCRAMNet trasfers. Please ntoe that at these time intervals the overhead of calling VI WILL affect your mesurements.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Have fun!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Ben&lt;/P&gt;</description>
      <pubDate>Mon, 11 May 2009 14:16:55 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/microsecond-tick-count/m-p/904847#M407835</guid>
      <dc:creator>Ben</dc:creator>
      <dc:date>2009-05-11T14:16:55Z</dc:date>
    </item>
  </channel>
</rss>

