Click here to Skip to main content
15,895,142 members
Home / Discussions / C#
   

C#

 
GeneralRe: Compute Speed of Download Algorithm Pin
Ravi Bhavnani3-May-06 13:03
professionalRavi Bhavnani3-May-06 13:03 
GeneralRe: Compute Speed of Download Algorithm Pin
zx2c43-May-06 13:06
zx2c43-May-06 13:06 
AnswerRe: Compute Speed of Download Algorithm Pin
Guffa3-May-06 12:58
Guffa3-May-06 12:58 
GeneralRe: Compute Speed of Download Algorithm Pin
zx2c43-May-06 12:59
zx2c43-May-06 12:59 
GeneralRe: Compute Speed of Download Algorithm Pin
Guffa3-May-06 21:58
Guffa3-May-06 21:58 
GeneralRe: Compute Speed of Download Algorithm Pin
Phil C5-May-06 20:13
Phil C5-May-06 20:13 
GeneralRe: Compute Speed of Download Algorithm Pin
zx2c46-May-06 9:16
zx2c46-May-06 9:16 
GeneralRe: Compute Speed of Download Algorithm Pin
Phil C6-May-06 10:01
Phil C6-May-06 10:01 
well now, I'm not going to do the whole thing for you.

I don't know how you have it set up so it's a bit tough for me to guess. but assuming you have a function that gets called every time a 1k chunk is downloaded I'd do it this way:

Forgive the lack of indenting, I never have figured out how to put tabs in these messages, I hit the tab key and my cursor jumps to the next block in the web page. I used spaces, but they don't make it either.

<br />
startdownload()<br />
{<br />
  m_sumx = 0;//running sum of the moving average..initialize it<br />
  m_numsamps = 3;//change to adjust sample size, otherwise just a fixed value<br />
}<br />
new1kblock()//this function gets called every time a 1k block arrives<br />
{<br />
  int elapsedtime = whateveryouuse();//pretend it's in seconds, <br />
  //I don't know what units you're dealing with, converting is up to you<br />
<br />
  //m_sumx holds the sum of the last 3 values, first subtract 1/3 to keep<br />
  //  it from growing to infinity<br />
  m_sumx -= m_sumx/m_numsamps;<br />
  //then add the latest elapsed time<br />
  m_sumx += elapsedtime;<br />
  //ok, now sumx is again the sum of the last three values<br />
  float dlspeed=0;<br />
  if(m_sumx>0)//be careful to avoid divide by zero, it can happen<br />
     dlspeed = 1024.0/(float)m_sumx/(float)m_numsamps;<br />
  //in this example dlspeed is now a value representing how fast we <br />
  // downloaded the last 3 1k chunks in bits/second.<br />
  // Display it however you desire<br />
<br />
}<br />

GeneralRe: Compute Speed of Download Algorithm Pin
zx2c46-May-06 13:30
zx2c46-May-06 13:30 
GeneralRe: Compute Speed of Download Algorithm Pin
Phil C6-May-06 15:32
Phil C6-May-06 15:32 
QuestionFull Text PDF Pin
smarttom993-May-06 11:47
smarttom993-May-06 11:47 
QuestionAdvice on best technologies for video / graphics work Pin
srev3-May-06 11:17
srev3-May-06 11:17 
QuestionHave associated files use currently running instance Pin
ilion blaze3-May-06 10:41
ilion blaze3-May-06 10:41 
AnswerRe: Have associated files use currently running instance Pin
Stefan Troschuetz3-May-06 11:14
Stefan Troschuetz3-May-06 11:14 
GeneralRe: Have associated files use currently running instance Pin
ilion blaze3-May-06 11:19
ilion blaze3-May-06 11:19 
GeneralRe: Have associated files use currently running instance Pin
Phillip M. Hoff3-May-06 19:31
Phillip M. Hoff3-May-06 19:31 
QuestionHow can I set a value in a cell of the DataGridView that contains a DataGridViewComboBoxColumn? Pin
Elvia Gonzalez3-May-06 9:51
Elvia Gonzalez3-May-06 9:51 
AnswerRe: How can I set a value in a cell of the DataGridView that contains a DataGridViewComboBoxColumn? Pin
Elvia Gonzalez3-May-06 13:09
Elvia Gonzalez3-May-06 13:09 
GeneralRe: How can I set a value in a cell of the DataGridView that contains a DataGridViewComboBoxColumn? Pin
goyal manish3-May-06 21:36
goyal manish3-May-06 21:36 
GeneralRe: How can I set a value in a cell of the DataGridView that contains a DataGridViewComboBoxColumn? Pin
Elvia Gonzalez4-May-06 7:29
Elvia Gonzalez4-May-06 7:29 
GeneralRe: How can I set a value in a cell of the DataGridView that contains a DataGridViewComboBoxColumn? Pin
Elvia Gonzalez4-May-06 8:13
Elvia Gonzalez4-May-06 8:13 
GeneralRe: How can I set a value in a cell of the DataGridView that contains a DataGridViewComboBoxColumn? Pin
Elvia Gonzalez4-May-06 14:31
Elvia Gonzalez4-May-06 14:31 
QuestionHow to pass form reference at run time. Pin
abhinish3-May-06 9:32
abhinish3-May-06 9:32 
AnswerRe: changing datagridview cell Pin
Office Lineman3-May-06 12:27
Office Lineman3-May-06 12:27 
QuestionCustom Tooltips Pin
siongc3-May-06 9:15
siongc3-May-06 9:15 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.