Bizarre clock() problem with connect (I think?)

Started by
12 comments, last by choffstein 16 years, 3 months ago
Quote:Original post by Adam_42
Note that it counts processor time used and not real time elapsed. When the process is asleep waiting for something very little processor time will be used.


Yes, this is probably the right answer. When waiting on the network, or a keypress, the thread is probably suspended and clock() has nothing to count. Apologies aviosity if my first reply led you down the wrong track here.

Advertisement
I got beaten by the rest, but the answer is simple: clock() returns the amount of time your application spent running(ie. clock cycles spent executing real code). If you call a blocking OS function, the thread gets suspended(Because the call passes the application border) and clock won't increase in time.

Any calls that are done to the OS and not contained within directly linked DLLs/Shared Objects do not count as process time.

If you want to find the time your application spent running(Wether it was suspended waiting for events to happen or waiting for a blocking OS call), implement the timer with timeGetTime().

Toolmaker

Adam_42, Kylotan, Toolmaker,

That's exactly what I was looking for, and what it looked like was going on. I really appreciate all the help everyone's given here...I'm gonna go start implementing a better timer [smile].

Thanks so much,
Aviosity
Hey, learn something new every day...I never knew that about clock()!
God I love this place.

This topic is closed to new replies.

Advertisement