Jump to content

This site uses cookies. By continuing to browse the site you are agreeing to our use of cookies. Find out more here. X


Moving Average

  • Please log in to reply
No replies to this topic

#1 Datenshi



  • Active Members
  • PipPipPip
  • 179 posts

Posted 24 August 2009 - 06:02 PM

Calculation for the Moving Average transfer speed. It calculates the average of speed samples taken approx over the last 5 seconds.

Plain Text         
#include <Array.au3> Func MovingAverage() ; updates stats during download     Dim $SpeedSamples[5]     $Accuracytimer = timerInit() ; for first loop     While @InetGetActive     $CalcAverage = 0     $BytesRead1 = @InetGetBytesRead     Sleep(1000)     $BytesRead2 = @InetGetBytesRead     _ArrayPush($SpeedSamples,Int($BytesRead2 - $BytesRead1)*(TimerDiff($Accuracytimer)/1000))     $Accuracytimer = timerInit()     $Ubound = Ubound($SpeedSamples) -1     For $x = 0 To $Ubound         $CalcAverage += $SpeedSamples[$x]     Next         $CalcAverage = $CalcAverage/$Ubound         $AverageSpeed = Int($CalcAverage/1024)     ConsoleWrite($AverageSpeed&" kb/s"&@CRLF) WEnd EndFunc

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users