I'm looking for IPC with high performance in Qt (v5.3) on Windows. In my final situation, I will have 3 (or more) producer process and one consumer process.
Before that, I made some tests using 1 producer thread and 1 consumer thread, using both QLocalSocket/QLocalServer (example) and QSharedMemory (example), and I have been surprised that the times are comparable.
In particular I got the following results (from first message till last message received):
Sending/Writing 1000 string message: QSharedMemory: 1020ms, QLocalSocket 1010ms Sending/Writing 5000 string message: QSharedMemory: 5010ms, QLocalSocket 5090ms Sending/Writing 10000 string message: QSharedMemory: 10097ms, QLocalSocket 10850ms
The questions are:
- Do you agree with this results or I probably wrong something in my code ?
- Are there some IPC methods with better performance in Qt ?
Thanks in advance. arthur86
UPDATE 23/10/2014
I take more time to investigate about this doubt, and I found a reasonable response. I discover that a big percentage of the previous time is used by context switch between thread. In particular, if I remove Thread::msleep(0); at the end of each cycle I'm able to reach lower computational time.
Eg.
- 1000 string message: less than 100ms both for QLocalSocket and QSharedMemory
- 5000 string message: less than 300ms both for QLocalSocket and QSharedMemory
- 10000 string message: less than 1000ms both for QLocalSocket and QSharedMemory
I think removing Thread::msleep(0)
is no a good idea. Isn't it ?
Could you suggest me some methods to improve performance with sleep instruction ?