I need to otimize performance of a piece of C++ code (ActiveX)
I'm using sockets and is use to _select() (in blocking mode) to wait
incomming data.
Profiling this component, i see the most CPU usage is in ... select()
call!!!
I can see a lot of time spent in call to WaitForSingleObject() !!!
Is WaitForSingleObject really using a lot of CPU?
There is another way to make a blocking usage of sokets?
Thank you in advance!
Pet.
> I need to otimize performance of a piece of C++ code (ActiveX)
> I'm using sockets and is use to _select() (in blocking mode) to wait
> incomming data.
Do not use select(). Use IO completion ports.
S
If you use ::Sleep(10000) to suspend execution for 10 seconds, the profiler
will report the Sleep costs 10 seconds.
--
Mike J. Deakins
For the shining star in my skies
"Peter Salom" <ps...@hotmail.com> wrote in message
news:%23G912BZ...@TK2MSFTNGP11.phx.gbl...
thanks, but...
I think the same about WaitForSingleObject(); it releases CPU to other
threads, but when i open TaskManager or Profiler, my object still eating CPU
time in select() call!!!
If really WaitForSingleObject doesn't use CPU, then the problem is bigger!
I can't use TaskManger/Profiler/Vtune to my waiting multihread app!!!
microsoft: What kind of tool i can use to measure "REAL" performance/CPU
usage of my mutihtreaded application?
Thank you,
Pet.
"Mike Deakins" <miked...@nospam.hotmail.com> wrote in message
news:unvr1gji...@TK2MSFTNGP11.phx.gbl...
[...]
WaitForSingleObject() does not use a lot of CPU. It is select() that uses a
lot of CPU. Consider this code:
while (1) WaitForSingleObject(object, 0);
Any profiler will tell you that the CPU time is spent in
WaitForSingleObject(). Does that mean that WaitForSingleObject() is bad? No,
it means that the code that calls it is bad. The same applies to select().
Do not use it.
S
"Slava M. Usov" <stripit...@gmx.net> wrote in message
news:es5aNG1i...@TK2MSFTNGP12.phx.gbl...
Your app is multithreaded? Are you sure that it isn't the others threads of
you app that are eating CPU during your select call? Try to debug-break in
your app while it is eating the CPU and see where the various threads are.
You can also use perfmon to watch the "% Processor Time" counter for *each*
of your threads.
Arnaud
MVP - VC
"Arnaud Debaene" <adeb...@club-internet.fr> wrote in message
news:eomg3%231iDH...@TK2MSFTNGP09.phx.gbl...
I hope it is not _so_ bad. But it is rather inefficient. Consider IO
completion ports instead.
S
"Peter Salom" <ps...@hotmail.com> wrote in message
news:eFqOpB2i...@TK2MSFTNGP12.phx.gbl...
"Slava M. Usov" <stripit...@gmx.net> wrote in message
news:eWL9oHai...@TK2MSFTNGP11.phx.gbl...