I am experiencing severe timing problems when using SmartInspect logging to a file and via tcp at the same time:
There is a background thread that reads data from the serial port writes them to a global variable that is protected with a mutex. After setting the variable, I have added some timing code that is supposed to tell me wether there are any timing issues. The thread receives a message 30 times a second.
The code looks like this:
var UpdateDiff: Int64; ThisUpdate: Int64; begin FCritSect.Enter; try QueryPerformanceCounter(ThisUpdate); UpdateDiff := ThisUpdate - FLastUpdated; FLastUpdated := ThisUpdate; // write the received data to the global variable finally FCritSect.Leave; end; // any logging is done after the protected code: // exiting here prevents the problem FLogSession.EnterMethod('SetData'); FLogSession.LogValue(lvDebug, 'LastUpdated', FLastUpdated); FLogSession.LogValue(lvDebug, 'UpdateDiff', UpdateDiff); FLogSession.WatchInt64('UpdateDiff', UpdateDiff); FLogSession.LeaveMethod('SetData'); end;
Now, what happens is that every 5 seconds the thread seems to freeze for quite a while (more than half a second). At the same time the SmartInspect console updates its display. If I put an exit at the position marked above, the issue goes away.
There are other threads that run in parallel and write to a different SiSession. I haven’t done any timing on them yet.
Am I doing anything wrong here? Or is SmartInspect just not suited for this kind of application?