NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

From where do the performance differences between the CVI user interface and the MFC user interface come?

I have some performance differences between my own Teststand user inface and the Teststand SequenceEditor. One execution of the MainSequence needs 5.5 seconds in my own GUI (develeoped with CVI). In the SequenceEditor.exe takes the execution only 4.3 seconds. I measured the same diffence between the NI sample GUI's developed with CVI (5.5 sec) and MFC++(4.3 sec). I didn' change the StationOptions (tracing and result recording...)!

 

How can I improve the performance of my GUI? Should I use C++ and MFC or I have to program some tricky application manager calls?

 

Thank you.

0 Kudos
Message 1 of 4
(3,791 Views)

I know of only one issue that would make a CVI UI slower. The issue is that the MSVC C-Runtime DLLs assume that the process executable file is built using the MSVC linker and stamped with its version. There is an ancient kludge in the MS code that keys off this version.

 

Future versions of TestStand and CVI will work around this issue. You can see if this is the problem you are seeing by pasting the following code into your UI and calling it from the first line of your main function. Let me know if it helps.

 

static void FixSlowMSVCHeap()
{
    PIMAGE_DOS_HEADER   pidh;
    PIMAGE_NT_HEADERS   pinh;

    pidh = (PIMAGE_DOS_HEADER)GetModuleHandle(NULL);

    if (!(pidh->e_magic != IMAGE_DOS_SIGNATURE || pidh->e_lfanew == 0))
    {      
        pinh = (PIMAGE_NT_HEADERS)(((PBYTE)pidh) + pidh->e_lfanew);

        if (pinh->OptionalHeader.MajorLinkerVersion < 6)
        {
            DWORD oldProtect, unused;
            if (VirtualProtect(&(pinh->OptionalHeader.MajorLinkerVersion), 4, PAGE_READWRITE, &oldProtect))
            {
                pinh->OptionalHeader.MajorLinkerVersion = 6; // set linker version high enough to make _set_sbh_threshold initialize with __V6_HEAP, not __V5_HEAP, which is three times slower for loading big files
                VirtualProtect(&(pinh->OptionalHeader.MajorLinkerVersion), 4, oldProtect, &unused);
            }
        }
    }   
}

0 Kudos
Message 2 of 4
(3,787 Views)

Thank you for your answer. Unfortunately the problem is not fixed. I tested the execution performance under different conditions. Result: I have the same performance with my own UI if I opened Teststand or LabWindows/CVI before. There is no app running in Teststand or CVI but the execution performance increase. Why? 

 

I use Teststand 4.0 and LabWindows/CVI 8.5. The sequence update another UI by DLL calls and uses often ProcessDrawEvents(). The execution speed raise to 2.7 sec if I hide all GUIs (minimized on task bar). I will not reach the maximum only the same speed the I have under Teststand SequenceEditor.

 

Did you have another idea? Thanks a lot. 

0 Kudos
Message 3 of 4
(3,753 Views)

sw4r -

 

Correct me if I'm wrong but it is my understanding that you are using our default TestStand 4.0 LabWindows/CVI UI. Are you using a custom process model? Could you provide your sequence file and code module files in an attached zip file and provide the steps to reproduce this execution time difference?

Manooch H.
National Instruments
0 Kudos
Message 4 of 4
(3,684 Views)