Re: What is the overhead of using windows messages?
"Nick Schultz" <nick.schultz@flir.com> wrote in message
news:uHItBfo7IHA.3976@TK2MSFTNGP06.phx.gbl...
It isn't exactly 100%, but hovers around 95%.
I think I am blocking because when I run stress tests on my system I get
pretty linear cpu usage as I simulate traffic on the bus:
when bus load is at ~75% (27902pks in 5s) I get cpu usage isa around 45%
when bus load is at ~50% (17439 pks in 5s) I get cpu usage of about 30%
when bus load is at ~25% (8720 pks in 5s) I get cpu usage of about 17%
each packet contains 8 bytes of data and there is some overhead for IDs
and such, probably another 3-4 bytes of data extra.
Does this mean that you are processing 5580 windows messages per second (for
the 75% case)? That is rather heavy. Using the callback instead of windows
messages is likely to be more efficient. But whether you use messages or a
callback you are still trying to execute your code 5580 times per second,
which is very heavy. For better efficiency, do you have an option to buffer
a number of packets in the driver and only process them in batches?
Note that this much CPU is being used just to respond to the messages that
CANLIB is sending, I then drop the packet since there aren't any clients
connected. So I'm not using WM_COPYDATA ,any IPC, or even queuing to my
client-handling threads.
Perhaps using a callback function will be more efficient?
From the CANLIB Documentation:
"The callback function is called in the context of a high-priority thread
created by CANLIB"
So I'm assuming that I wouldn't be able to send any messages as that
thread will probably not be in the message loop, correct?
Not correct. You don't have to be in a message loop to send messages.
--
Scott McPhillips [VC++ MVP]