Benchmark Execution Speed of LabVIEW Applications

Sunday, October 26, 2003

About execution speed of LabVIEW Application you can read here. This article shows following results:

Below I would like to show more realistic test with comparison "C vs LabVIEW".
In LabVIEW I will try to search maximum of array by different methods. Of course, for benchmark measurement we need more complicated task, but in general it is true, that C-based code much more faster, then LabVIEW code (I means "native LabVIEW code", without using external DLLs! In comparison above, for example, measurement of "Power Spectrum" absolutely incorrect, because (I pretty sure) was based on external DLL - based code. In additional, we don't know about implementation's details. Why benchmarking was done without demonstration of source code, which was used for measurement?

In My Benchmark Test I will try to search maximum of array (I16). For my test (Intel P4, 1.6 GHz) 25 millions elements will be enough.
Below my simple benchamrk with complete source code:

1. Searching in cycle:

2. Search by NI FindMinMax:

3. Search by C (as external code)

C-Code was compiled twice:
C-Code for MSVC compiler:


int16 FindMaxLV1DArray(TD1Hdl in_array)
{
int32 i;
int16 min = 32767, max = -32768, curr;

for (i=0; i < ( (*in_array)->dimSize ); i++){
curr = (*in_array)->arg1[i];
if ( curr > max ) max = curr;
if ( curr < min ) min = curr;
}
return max;
}


And C-Code for Intel C++ Complier.
This complier have possibilities for cycle-vectorization, but it will be possible only with small modification of my code:

int16 FindMaxLV1DArrayVect(TD1Hdl in_array)
{
//if you use LV data types, the size information is inside the structure.

int32 i;
int16 min = 32767, max = -32768, curr;
int16 *ptr = (*in_array)->arg1;

for (i=0; i < ( (*in_array)->dimSize ); i++){
curr = ptr[i];
if ( curr > max ) max = curr;
if ( curr < min ) min = curr;
}
return max;
}


 

Download complete source code (LabVIEW 7.0 - speed_test_1.zip /69K)

Results (no comments):