hi ,
we are still having problems to calculate transfer speed accurately.
beside the speed(long) method i posted above ,here is the method i use in ProgressMonitor:
public void bytesTransferred(long bytes) {
util.Trace.log(bytes + " transferred");
long b = r.numBytes + bytes;
double done = ((double) b / r.tSize);
done *= 100D;
main.setProgressBar((int) done);
long end = System.currentTimeMillis();
long timeTaken = end - r.startTime;
//timeTaken = (timeTaken / 1000);
long kb = 0;
if (timeTaken != 0)
kb = ((b) / timeTaken);
else
kb = ((b));
String speed = r.speed(b);
String timeRemaining = r.remainingTime(r.tSize, b, kb);
String currSize = util.UploadSystem.fileSize(b);
String message = "Status: " + currSize + " of "
+ util.UploadSystem.fileSize(r.tSize) + ", " +
timeRemaining + ", " + speed;
main.setStatusLabel(message);
}
i would appreciate you help me make the transfer rate calculation correctly .
thanks