From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
11-17-2006 10:26 AM
11-24-2015 02:44 PM
I know this is old, but I thought I'd chime in with my results. Same set of questions, I need very accurate timing to count pulses in a certain arbitrary window.
These pages were helpful:
Attached is my sample CVI 2015 project to simply uses the Windows method as well as the CVI Timer() function to measure time differential before and after a "Hello, world" write.
If you don't want to bother with the project, here are the results:
Color code represents minimum seconds, but shouldn't be confused with "good" or "bad".
As you can see, Timer() calls got very good results. Also note that Timer by default attempts to get 1us timing, better even that the multimedia timers, which explains its performance!
11-25-2015 12:53 AM
To be honest, I don't understand the 'take-home' message... what do you consider 'very good' results? (I can see that the minimum time changes by a factor of 10 in both cases)
01-26-2016 03:32 PM
Hi ElectroLund, I want to thank you for your sample project from a couple of months ago.
I also wanted to mention to you and to any other interested parties out there that your post made me curious on just how fast I could run your while-loop, while writing your small buffers to a modern, high performance SSD drive, using both the "WinAPI" and the "CVI" approach (which implies that I took out some of your self-imposed delays in your sample project).
The SSD is a Kingston RBU-SMS100S3256GA (it is an MSATA SSD that ships as the native boot drive with the Acer Aspire V3-772G-7616 Windows 8.1 x64 laptop). It is a stock laptop, with no BIOS tricks, and it has an Intel Core i7-4712MQ, and the stock 8 GB DDR3L RAM in it.
My edits to your while-loop look like this (note that I opened up the precision on the time-stamp to 18 decimal places):
while (go == 1)
{
//----------------
// WinAPI approach
//----------------
QueryPerformanceFrequency(&clockFrequency);
QueryPerformanceCounter(&startTime);
WriteLine(fileHandle, "Now is the time for all good men to come to the aid of their country.", -1);
QueryPerformanceCounter(&endTime);
delta.QuadPart = endTime.QuadPart - startTime.QuadPart;
secondsWIN = (double)delta.QuadPart / clockFrequency.QuadPart;
//----------------
// CVI approach
//----------------
secondsCVI = Timer();
WriteLine(fileHandle, "Now is the time for all good men to come to the aid of their country.", -1);
secondsCVI = Timer() - secondsCVI;
//----------------
// now write results to disk
//----------------
sprintf(buffer, "%20.18f\t\t%20.18f", secondsWIN, secondsCVI);
WriteLine(fileHandle, buffer, -1);
}
The output.txt file grows quickly after only a couple of seconds, but here is a tiny snippet from it:
Win API CVI
Now is the time for all good men to come to the aid of their country.
Now is the time for all good men to come to the aid of their country.
0.000005354974570565 0.000007000000000000
Now is the time for all good men to come to the aid of their country.
Now is the time for all good men to come to the aid of their country.
0.000005354974570565 0.000006000000000000
Now is the time for all good men to come to the aid of their country.
Now is the time for all good men to come to the aid of their country.
0.000005801222451445 0.000005000000000000
Now is the time for all good men to come to the aid of their country.
Now is the time for all good men to come to the aid of their country.
0.000005801222451445 0.000006000000000000
Now is the time for all good men to come to the aid of their country.
Now is the time for all good men to come to the aid of their country.
0.000005801222451445 0.000005000000000000
Now is the time for all good men to come to the aid of their country.
Now is the time for all good men to come to the aid of their country.
0.000005354974570565 0.000006000000000000
Now is the time for all good men to come to the aid of their country.
Now is the time for all good men to come to the aid of their country.
0.000005354974570565 0.000005000000000000
Now is the time for all good men to come to the aid of their country.
Now is the time for all good men to come to the aid of their country.
0.000005354974570565 0.000005000000000000
Now is the time for all good men to come to the aid of their country.
Now is the time for all good men to come to the aid of their country.
0.000005801222451445 0.000006000000000000
Now is the time for all good men to come to the aid of their country.
Now is the time for all good men to come to the aid of their country.
0.000005354974570565 0.000006000000000000
So one take-away from this is that CVI's "Timer ()" function rounds to the nearest microsecond, but it puts you in the ballpark for when you need time slices down in that range.
Thanks again...!
JB