Compute bytes per seconds ?

BlitzMax Forums/BlitzMax Programming/Compute bytes per seconds ?

Filax(Posted 2007) [#1]
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... :)


JazzieB(Posted 2007) [#2]
Why complicate matters?

Just use the numbers of bytes sent/received divided by the number of seconds since the transfer began?


Filax(Posted 2007) [#3]
divided by the seconds or millisecs ?


ziggy(Posted 2007) [#4]
if you want bytes per second, divide by seconds. :D


Filax(Posted 2007) [#5]
Something like this ?


MyTime=MilliSecs()/1000

While Not Eof(StreamA)
........

Print ">"+(DownloadedBytesNumber / ((MilliSecs()/1000) - MyTime))
Wend


BladeRunner(Posted 2007) [#6]
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.


Filax(Posted 2007) [#7]
Many thanks !