Reload this Page

Not Bug exactly: Computation of Connection time remaining


Reply
Thread Tools
Search this Thread
Display Modes
  #1  
Old August 20th, 2006, 06:48 PM
bsdman bsdman is offline
Junior Member
 
Join Date: Aug 2006
Posts: 2
Default Not Bug exactly: Computation of Connection time remaining

I posted it on the Gnutella forums. Forgive the referral, I just didn't want to type it again:

http://www.gnutellaforums.com/showthread.php?t=60210

Any comments are appreciated.
Reply With Quote
  #2  
Old August 20th, 2007, 05:05 PM
Judge Zargabaath's Avatar
Judge Zargabaath Judge Zargabaath is offline
Senior Member
 
Join Date: Aug 2007
Location: In a dream
Posts: 281
Smile Copy and paste

This is what was said: (not by me) Or something close i dunno how to do code properly

I have read some of the code, and as I understand it, my suggestion could be implemented by changing the DownloadDataLine class in the com.limegroup.gnutella.gui.download package as follows:


Code:
 
/* Beginning on line 786 */
// If we have a valid rate (can't compute if rate is 0),
// then determine how much time (in seconds) is remaining.
if ( _speed > 0) {
double kbLeft = ((_size/1024.0) - 
(_amountRead/1024.0));
_timeLeft = newTimeRemaining((int)(kbLeft / _speed));
}
And then, add a new private method to do the rolling average, along with some member data:

Code:
 
// This member data is for the rolling average.
private final int N = 10; // the number of times to save, adjust at leasure
private boolean full = false; // to only use the average when we have N #s
private int index = 0; // the index for the element to replace in times[]
private int times[] = new int[N]; // the list of times
/**
* This method calculates the new time remaining based on a rolling average.
* @author bsdman
*/
private int newTimeRemaining(int anotherTime)
{
times[index++] = anotherTime;
if(index == N)
{
index = 0;
full = true;
}
if(!full)
return anotherTime; // since we can't average yet
// otherwise, take the average
// TODO this average could probably be written more efficeiently
long total = 0;
for(int i = 0; i < N; i++)
total += times[i];
return (int)(total/N);
}
Just to save time for people with slow connections Change it back to what it is if you get the chance
__________________
Zargabaath

Skin maker

Download LimeWire
LimeWire on Wikipedia
Reply With Quote
  #3  
Old August 21st, 2007, 03:36 AM
bsdman bsdman is offline
Junior Member
 
Join Date: Aug 2006
Posts: 2
Default Problem solved.

Thanks for the repeat of the message.

Perhaps this has already been acted upon. In the version of Limewire I just updated to, my code isn't in it, but the download times are not screwy anymore. Good work.
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Forum Jump


All times are GMT. The time now is 06:19 AM.


Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.