11-19-2019 07:03 AM
I see nothing in that code that should be an CPU-load concern.
Over 1000 calls for a total of 46.7 msec ain't bad. The fact that the 1 longest call took 33.7 means the other 1000+ *more typical* calls actually only took 13 msec.
The rest of it is the kind of thing I just chalk up to Windows being Windows. It simply isn't uncommon to see occasional timing variations in 10's of msec, sometimes more. Nature of the beast, that's my conclusion.
-Kevin P
11-19-2019 07:46 AM
The variance you are seeing is likely the first iteration. The rest probably runs at far below 1 ms.
Measuring performance is really tricky. There are many threads in the forum about it. I would also suggest you run it in runtime and add some performance measurement timers, since that is a whole other story and it is probably not interesting or even indicative what you are seeing in the IDE.
11-19-2019 08:22 AM
How often is the GUI being updated?
Ben
11-19-2019 10:03 AM
You did not take my suggestion for processing the messages. Don't dequeue the elements individually in a loop (with an arbitrary 5 ms delay in it) but dequeue ALL of the elements at once using a queue flush. The flush has the option of returning all of the elements in the queue at once. Then process elements in a for loop with auto indexing.
Try the following:
11-19-2019 10:06 AM
"... a loop (with an arbitrary 5 ms delay in it)..."
Again at what rate is the UI being updated?
5ms >>> 200 updates a second is silly when the display can not update that fast.
Ben
11-19-2019 10:09 AM - edited 11-19-2019 10:21 AM
@Ben wrote:
"... a loop (with an arbitrary 5 ms delay in it)..."
Again at what rate is the UI being updated?
5ms >>> 200 updates a second is silly when the display can not update that fast.
Ben
The arbitrary delay was in the loop dequeuing the elements from the queue and formatting the elements into a string. There was no UI interaction in the consumer loop. It did write to a global which indicating the line count in the log file but there was no UI in the consumer.
When building a string to write to file there is no need to have a Wait within the loop building the string.