From: | Yves Grabowsky |
Date: | 04 Dec 99 at 12:00:01 |
Subject: | Re: cps counter |
From: YvesGrabowsky@t-online.de (Yves Grabowsky)
Hello Rod,
On 04-Dez-99 wrote Rod Schnell (rodsch@telusplanet.net):
> From: Rod Schnell <rodsch@telusplanet.net>
>
> Hello Yves
>
> On 04-Dec-99, Yves Grabowsky wrote:
>> From: YvesGrabowsky@t-online.de (Yves Grabowsky)
>>
>> Hi,
>> I'm trying to calculate the cps of a transfer with the following code:
>>
>> --------CUT HERE-----------
>> long n, temp, cps;
>> time_t start, current;
>>
>> start = time(&start);
>>
>> do
>> {
>> n = Sock_Recv(dtc, buf, LEN_RECVBUF);
>> temp += n;
>> if (n>0)
>> Write(outfile, buf, n);
>>
>> current = time(¤t); // cps calculation
>> current -= start;
>> cps = temp/current;
>> } while(n); // receive loop
>>
>> (temp holds the bytes received)
>> -----------CUT HERE-------------
>>
>> 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()?
> Regards Rod
Cu,