Compute bytes per seconds ?
BlitzMax Forums/BlitzMax Programming/Compute bytes per seconds ?
| ||
Hi I'm playing with TCP Stream :) and i want to know how to compute the bytes per seconds during a file transfer ? What i know (server/client)? - I know how many bytes are received/sended. - I know the file size. - I know the transfer buffer size If anybody can give me the magic formula... :) |
| ||
Why complicate matters? Just use the numbers of bytes sent/received divided by the number of seconds since the transfer began? |
| ||
divided by the seconds or millisecs ? |
| ||
if you want bytes per second, divide by seconds. :D |
| ||
Something like this ? MyTime=MilliSecs()/1000 While Not Eof(StreamA) ........ Print ">"+(DownloadedBytesNumber / ((MilliSecs()/1000) - MyTime)) Wend |
| ||
Yes. And you could of course make an output only once a second - would be better to read then. Something like this: starttime = millisecs() While not EOF(......) .... If MilliSecs() > timer Then downedbytespersecond= downedbytes/((MilliSecs()+1.0-starttime)/1000) timer = MilliSecs()+1000 EndIf Print "Bytes per Sec.: " + int(downedbytespersecond) Wend Caution: downedbytespersecond should be a float, cause it could produce an 'devide integer by zero' if it was an integer. For the same reason one millisec is added. |
| ||
Many thanks ! |