LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

microsecond tick count

To do some fast and dirty performance analysis, I was wondering if I could get less than ms resolution from anything in LabView.
 
I found this post
 
 
Which seems to ask the same question, but the answer seems more like a CVI answer than LabView.
 
Can you access the Query... API from LabView?
If so, can someone please tell me how?
 
Thanks
 
0 Kudos
Message 1 of 15
(15,492 Views)

In addition to the answer you linked, there's also a LabVIEW-based 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).

It was intended for use under Pentium-based RT systems, but I recall using it under Windows as well.  Here's a link.

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.

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.  Also note that sometimes performance during a benchmark can be significantly better than it is in normal use.  The tight looping may keep a lot of things in a local cache and require many fewer than normal wait states for memory access.

Good luck!  Despite the quirks and difficulties of performing benchmarks, it's still good to take your best shot at it. 

-Kevin P.

ALERT! LabVIEW's subscription-only policy came to an end (finally!). Unfortunately, pricing favors the captured and committed over new adopters -- so tread carefully.
0 Kudos
Message 2 of 15
(15,486 Views)

Thanks a lot.  I will give this a try.

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).  I realize that just won't happen with a PC, but I would like to get a general idea what I'm up against.

 

Thanks again.

 

0 Kudos
Message 3 of 15
(15,480 Views)
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 this only works on a windows system.  
 
If you need to tweak it. I wrote the code originally in LV7, which is why I'm internally using a pair of int32s instead of a single int64.
0 Kudos
Message 4 of 15
(15,476 Views)

Thanks a bunch.

I will take a look at this later.

LabView 7 is perfect as I am using 7.1

 

0 Kudos
Message 5 of 15
(15,472 Views)
I updated it to use int64, so it's just one VI now
Message 6 of 15
(15,472 Views)

I found an old version compiled under 7.1

Hopefully this one should work for you

0 Kudos
Message 7 of 15
(15,466 Views)

Hi Matt,

I believe you made an error in your code to join two 32-bit numbers.  The high part should be multiplied by 2^32 = 4,294,967,296 (an even number), not 4,294,967,295.  Unless you are trying to compensate for the code processing time to do the calculation.

Regards, Jay

0 Kudos
Message 8 of 15
(15,140 Views)
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.  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.
0 Kudos
Message 9 of 15
(15,114 Views)
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?
0 Kudos
Message 10 of 15
(14,912 Views)