BazisLib::Network::RateCalculator Class Reference

Performs transfer rate calculation. More...

#include <ratecalc.h>

Collaboration diagram for BazisLib::Network::RateCalculator:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 RateCalculator (unsigned AveragingTime=-1)
 Creates the sliding average rate calculator.
void ReportNewAbsoluteDone (ULONGLONG Done)
void ReportNewRelativeDone (ULONGLONG Done)
void SetAveragingTime (unsigned NewTime)
void Reset (ULONGLONG InitialValue=0)
TimeSpan GetExpectedRemainingTime (ULONGLONG TotalDownloadSize)
unsigned GetBytesPerSecond ()

Static Public Member Functions

static String FormatByteCount (ULONGLONG value)
static String FormatTimeSpan (const TimeSpan &span)

Protected Member Functions

void UpdateAverage ()

Private Types

enum  { EstimatedTimeRateFilteringCoef = 100 }

Private Attributes

unsigned m_AveragingTime
ULONGLONG m_Downloaded
unsigned m_CachedValue
DateTime m_StartTime
AtomicOperationLock m_Lock
ExponentialFilterI32 m_RateFilter


Detailed Description

Performs transfer rate calculation.

The RateCalculator class can be used for realtime transfer rate calculation. It requires the number of bytes transferred at a certain point of time. All time evaluation and calculation is done automatically.

Remarks:
The estimated remaining time prediction algorithm uses ExponentialFilterI32 class to provide more smooth results. To alter the smoothing depth, alter the EstimatedTimeRateFilteringCoef constant.

Member Enumeration Documentation

anonymous enum [private]

Enumerator:
EstimatedTimeRateFilteringCoef 


Constructor & Destructor Documentation

BazisLib::Network::RateCalculator::RateCalculator ( unsigned  AveragingTime = -1  ) 

Creates the sliding average rate calculator.

Parameters:
AveragingTime Specifies the averaging time in milliseconds -1 stands for overall rate calculation.


Member Function Documentation

static String BazisLib::Network::RateCalculator::FormatByteCount ( ULONGLONG  value  )  [inline, static]

static String BazisLib::Network::RateCalculator::FormatTimeSpan ( const TimeSpan span  )  [inline, static]

Here is the call graph for this function:

unsigned BazisLib::Network::RateCalculator::GetBytesPerSecond (  ) 

TimeSpan BazisLib::Network::RateCalculator::GetExpectedRemainingTime ( ULONGLONG  TotalDownloadSize  ) 

void BazisLib::Network::RateCalculator::ReportNewAbsoluteDone ( ULONGLONG  Done  ) 

void BazisLib::Network::RateCalculator::ReportNewRelativeDone ( ULONGLONG  Done  ) 

void BazisLib::Network::RateCalculator::Reset ( ULONGLONG  InitialValue = 0  )  [inline]

Here is the call graph for this function:

void BazisLib::Network::RateCalculator::SetAveragingTime ( unsigned  NewTime  )  [inline]

void BazisLib::Network::RateCalculator::UpdateAverage (  )  [protected]


Member Data Documentation


The documentation for this class was generated from the following file:
SourceForge.net Logo