Class NetworkAdminSpeedTesterBTImpl.TorrentSpeedTestMonitorThread
- java.lang.Object
-
- java.lang.Thread
-
- com.biglybt.core.networkmanager.admin.impl.NetworkAdminSpeedTesterBTImpl.TorrentSpeedTestMonitorThread
-
- All Implemented Interfaces:
java.lang.Runnable
- Enclosing class:
- NetworkAdminSpeedTesterBTImpl
private class NetworkAdminSpeedTesterBTImpl.TorrentSpeedTestMonitorThread extends java.lang.Thread
-------------------- helper class to monitor test. -------------------
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
AVE
(package private) java.util.List
historyDownloadSpeed
(package private) java.util.List
historyUploadSpeed
static long
MAX_PEAK_TIME
static long
MAX_TEST_TIME
(package private) long
peakRate
(package private) long
peakTime
(package private) long
startTime
static java.lang.String
STD_DEV
(package private) Download
testDownload
(package private) java.util.List
timestamps
-
Constructor Summary
Constructors Constructor Description TorrentSpeedTestMonitorThread(Download d)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private java.util.Map
calculate(java.util.List history)
Calculate the avererage and standard deviation for a history.(package private) NetworkAdminSpeedTesterResult
calculateDownloadRate()
Based on the previous data cancluate an average and a standard deviation.(package private) long
checkForNewPeakValue(DownloadStats stat, long lastTotalDownload, long currTime)
We set a new "peak" value if it has exceeded the previous peak value by 10%.(package private) boolean
checkForTestDone()
In this version the test is limited to MAX_TEST_TIME since the start of the test of MAX_PEAK_TIME (i.e.private java.util.List
convertSumToDeltas(java.util.List sumHistory)
Convert a list of sums into a list of download rates per second.private int
findIndexPeak(int numStats)
void
run()
void
updateTestProgress(long currTime, DownloadStats stats)
Calculate the test progression as a value between 0-100.-
Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, onSpinWait, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, suspend, toString, yield
-
-
-
-
Field Detail
-
historyDownloadSpeed
final java.util.List historyDownloadSpeed
-
historyUploadSpeed
final java.util.List historyUploadSpeed
-
timestamps
final java.util.List timestamps
-
testDownload
final Download testDownload
-
MAX_TEST_TIME
public static final long MAX_TEST_TIME
- See Also:
- Constant Field Values
-
MAX_PEAK_TIME
public static final long MAX_PEAK_TIME
- See Also:
- Constant Field Values
-
startTime
long startTime
-
peakTime
long peakTime
-
peakRate
long peakRate
-
AVE
public static final java.lang.String AVE
- See Also:
- Constant Field Values
-
STD_DEV
public static final java.lang.String STD_DEV
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
TorrentSpeedTestMonitorThread
public TorrentSpeedTestMonitorThread(Download d)
-
-
Method Detail
-
run
public void run()
- Specified by:
run
in interfacejava.lang.Runnable
- Overrides:
run
in classjava.lang.Thread
-
updateTestProgress
public void updateTestProgress(long currTime, DownloadStats stats)
Calculate the test progression as a value between 0-100.- Parameters:
currTime
- - current time as long.stats
- - Download stats
-
calculate
private java.util.Map calculate(java.util.List history)
Calculate the avererage and standard deviation for a history.- Parameters:
history
- - List of Long values but that contains the sum downloaded at that time.- Returns:
- Map
with values "ave" and "stddev" set
-
convertSumToDeltas
private java.util.List convertSumToDeltas(java.util.List sumHistory)
Convert a list of sums into a list of download rates per second.- Parameters:
sumHistory
- - Listwith download sum for each second. - Returns:
- - List
with the download rate for each second.
-
findIndexPeak
private int findIndexPeak(int numStats)
-
calculateDownloadRate
NetworkAdminSpeedTesterResult calculateDownloadRate()
Based on the previous data cancluate an average and a standard deviation. Return this data in a Map object.- Returns:
- Map
as a contain for stats. Map keys are "ave" and "dev".
-
checkForTestDone
boolean checkForTestDone()
In this version the test is limited to MAX_TEST_TIME since the start of the test of MAX_PEAK_TIME (i.e. time since the peak download rate has been reached). Which ever condition is first will finish the download.- Returns:
- true if the test done condition has been reached.
-
checkForNewPeakValue
long checkForNewPeakValue(DownloadStats stat, long lastTotalDownload, long currTime)
We set a new "peak" value if it has exceeded the previous peak value by 10%.- Parameters:
stat
- -lastTotalDownload
- -currTime
- -- Returns:
- total downloaded so far.
-
-