Using the TestStand Seconds Function or Wait Step May Result in Incorrect Elapsed Time

Updated Dec 8, 2017

Reported In

Software

  • TestStand

Issue Details

The elapsed time calculated from the TestStand Seconds(True) function does not return the expected value in my sequence. Instead, it is returning an elapsed time that increases at a slower rate than the actual time elapsed. If I change the returnSecondsSinceStartup parameter from True to False on the problem machine, the sequence executes properly and returns the appropriate elapsed time.

Also, the Wait steps in my sequence are taking 1.5x to 2x longer to execute than the time specified in the step. I have tested the same TestStand sequences on other machines, and they execute as expected on most machines. Only some machines exhibit this problem. 

Why am I experiencing incorrect behavior on some machines when using Wait steps and when calling the Seconds() function with the returnSecondsSinceStartup parameter set to True ?

Solution

Check with your computer’s manufacturer to see if any updates to the BIOS, CPU driver, or chipset driver are available. If so, this problem might be resolved by one of those updates. Check if you have the latest Windows updates and service packs installed. If updating the BIOS, CPU driver, chipset driver, and operating system does not resolve the issue or an update is not available, Microsoft recommends adding the /usepmtimer switch to the machine’s Boot.ini file. For step-by-step instructions of how to accomplish this, please see the Workaround section of Microsoft Knowledge Base article 895980. Even though this KnowledgeBase article is specific to machines using AMD CPUs, this workaround has solved the problem for some customers with machines using Intel CPUs as well.

Note: An incorrect modification to the machine’s Boot.ini file might leave the machine in an unbootable state. National Instruments highly recommends that you back up any important documents or files on the machine prior to implementing the steps suggested by the Microsoft KnowledgeBase articles linked in this document.

Additional Information

The TestStand Wait step and the Seconds() function (with returnSecondsSinceStartup = True) both call the Windows SDK function QueryPerformanceCounter(). Users have generally experienced this behavior on multiprocessor computers and/or computers with SpeedStep or similar variable-speed processor technology. The MSDN Help for QueryPerformanceCounter() states the following: 
 
"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)…"

Microsoft reports this behavior occurring on some machines with AMD processors on Windows 2000, Windows XP, and Windows Server 2003 operating systems as explained in Microsoft KnowledgeBase articles 895980 and 938448.

The TestStand Seconds() function uses a different Windows SDK function when you pass False to the returnSecondsSinceStartup parameter. Thus, calling Seconds(False) does not exhibit the incorrect behavior. However, the Wait step will always call QueryPerformanceCounter() and is subject to being affected by the issues described in the Microsoft KnowledgeBase articles linked above.

WAS THIS ARTICLE HELPFUL?

Not Helpful