In the test modules for IMC a few stopwatches are included to be able to time Command and DataReady calls. The result is written directly in the module output window.
Its implemented both in the .Net 6 sample IMC modules and in the Noah 4 IMC2 sample modules.
Get Coupler Codes and Clear Curve Commands has Stopwatch included in the IMCClient.
Dataready(String[]) and Request new Target has Stopwatch in the IMCServer.
Stress test
To simulate live data from a REM module via DataReady the button Start Measurement in the IMCClient samples will send a command to the IMCServer that will as fast as possible in separate thread send 100 curves one by one where all measurement points are filled out. The time each call takes is logged in the IMCServer output window. Average time for call in calculated and written.
Performance result on a fast developer PC
Comments:
The following factors make the REST interface slower especially Command. In previous implementation there is a direct connection between IMC Client and Server which make every call happen at once.
In REST implementation the following happens in Command.
Module makes an object (e.g. IMC command object) with data and sends a Command.
The Proxy first serialize the data object (the module process) when it leaves the module and then de-serializes it back to an object in the proxy itself. (The proxy process)
Then the data object is send through a direct connection form one proxy (IMCClient) instance to another (IMCServer) like previous IMC connection in Noah 4. This happens at once.
Then the Proxy sends an event to the IMCServer module again first serializing and de-serializing data.
Now the module (IMCServer) holds the original data as it was send from the client.
Now meanwhile the proxy waits for the module (IMCServer) to post the result of the data. (The proxy first check at 2 ms and then every 10 ms for the result)
Now the module post the command result which has to be serialized and de-serialized in the proxy.
Then again the result flow from IMCServer proxy to the IMCClient proxy which on return to the initiating module again has to serialize and de-serialize the data. Now the IMCClient has the result of the Command.
For DataReady its much more simple and faster since there is no return value.
The is only to times Serialize/De-serialize.
Recommendation:
Seen from a performance perspective its recommended to use Command only to “activate“ the IMCServer and tell it what it should do. Don't use it to get a lot of Data.
We recommend that DataReady is used to send the actual data.