From: | Rod Schnell |
Date: | 04 Dec 99 at 18:46:15 |
Subject: | Re: cps counter |
From: Rod Schnell <rodsch@telusplanet.net>
Hello Yves
On 04-Dec-99, Yves Grabowsky wrote:
> From: YvesGrabowsky@t-online.de (Yves Grabowsky)
>
>>> Everytime I execute this code it crashes, without the cps calculation it
>>> runs perfectly. Whats wrong with this?
>>>
>>
>> Divide by zero error maybe? time() returns the current time in seconds, it
>> likely takes less than a second between start and current.
>>
>
> Maybe thats right, but then an exception would occur, wouldn't it?
> And how can I solve this? Using GetSysTime()?
>
Simplest way to find out if that is the problem would be to comment out the
line with the division, recompile and see if it still crashes. In that case, a
simple fix would be...
if(current > start)
{
current -= start;
cps = temp/current;
}
else cps = temp;
Personally, I'd use timer device and calculate the cps rate every second
or so rather than after every call to recv... Especially if the rate is being
displayed in a GUI.
Regards Rod