Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Differences in Speed Results using MessageBasedSessionReader and MessageBasedSession.

I have a speed test using a raw socket connection that causes an instruments to return a large buffer (43000 bytes of data). Each line of data returns a 43 bytes that includes "#0", 10 floats, and a '\n' character.

I'm using C# in Microsoft Visual Studio .NET 2005 to read the data in a loop. There are two test cases to read the data. (mSession is a MessageBasedSession object). In the first case, data is read using mSession.ReadByteArray(43). In the second case, MessageBasedSessionReader methods are used to read the data.

                ....
                MessageBasedSessionWriter lWriter = new MessageBasedSessionWriter(mSession);
                MessageBasedSessionReader lReader = new MessageBasedSessionReader(mSession);
                ...
                ...
                for (int j = 0; j < lNumPoints10; ++j) // lNumPoints = 1000
                {
                    if(lTestType == 1)
                   {
                        mSession.ReadByteArray(43);
                    }
                   else
                   {
                        lChar[0] = lReader.ReadChar(); // Read '#'
                        lChar[1] = lReader.ReadChar(); // Read '0'
                        lData = lReader.ReadSingles(10);
                        lChar[2] = lReader.ReadChar(); // Read '\n'*
                    }
                }

I've verified the data returned is correct in both cases. Yet, there is a huge performance hit using the higher level functions of lReader instead of mSession. If fact the time hit is related to the Timeout property of mSession as it takes exactly 2 seconds longer to receive the data in the second case (Changing the timeout property changes the result). But, a timeout exception is not being intercepted by my code.

Any idea to why this would happen?
0 Kudos
Message 1 of 5
(3,817 Views)
 

Hi,

What version of NI-VISA are you using? Here is a link to the current version of VISA.

Can you post a NI-Spy capture for each of these two cases? The simpler the test program captured can hopefully help us narrow down the cause of this problem. Thanks!

Regards,

Missy S.
Project Engineer
RoviSys
Message 2 of 5
(3,786 Views)
I'm using the latest version, VISA 4.0.

Attached are a copy of the captures. Basically, a script is downloaded to my unit. After s1() is sent, the script executes, and the unit returns the string "End" when complete.  Even though I'm reading 4 characters in each case, the MessageBasedSessionReader takes longer.



Download All
0 Kudos
Message 3 of 5
(3,753 Views)
Regarding my last post, this test is slightly different from the first I posted, but the results are the same. The first test read a binary number, while this test merely looks for the string "End."

In my code, I have the following to read the return data.

#if USE_MESSAGE_READER
mReader.ReadChars(4);
 #else
mSession.ReadByteArray(4);
#endif
0 Kudos
Message 4 of 5
(3,754 Views)

Hi,

I was able to reproduce the issue you are seeing. I noticed from the NI-Spy capture you posted that the MessageBasedSessionReader's viRead (the VISA read) command was timing out. I will investigate this issue further and let you know what I find.

Regards,

Missy S.
Project Engineer
RoviSys
Message 5 of 5
(3,730 Views)