Friday, May 04, 2007

How to calculate download Speed using and java script code

How to calculate download Speed using and java script code
1) using code
private void CalculateDownloadTime(double fileSizeMB,double fileSizeKB,int speed,ref int timeHour,ref int timeMinute,ref int timeSec)
double downloadTime = 0;
if (fileSizeMB != 0)
downloadTime = (fileSizeMB * Constant.FILE_SIZE_KB * 8.192) / speed;
else if (fileSizeKB != 0)
downloadTime = (fileSizeMB * 8.192) / speed;
timeHour = Convert.ToInt32(downloadTime) / 3600;
timeMinute = (Convert.ToInt32(downloadTime) % 3600) / 60;
timeSec = Convert.ToInt32(downloadTime) % 60;
Example to call above function
int timeHour =0;
int timeMinute =0;
int timeMinute =0;
CalculateDownloadTime(30,0,56, ref timeHour, ref timeMinute, ref timeMinute);
2) using Java Script
<script language="JavaScript" type="text/javascript">
var speeds = new Array(
new Array("9.6 Modem", "9.6"),
new Array("14.4 Modem", "14.4"),
new Array("19.2 Modem", "19.2"),
new Array("28.8 Modem", "28.8"),
new Array("33.6 Modem", "33.6"),
new Array("56 Kb Modem", "56"),
new Array("Single Channel ISDN (64Kbps)", "64"),
new Array("Dual Channel ISDN (128Kbps)", "128"),
new Array("Asymmetric DSL (ADSL)", "384"),
new Array("Single-pair HDSL (S-HDSL)", "768"),
new Array("Consumer DSL (CDSL)", "1024"),
new Array("T1", "1544"),
new Array("HDSL", "1544"),
new Array("T3", "46080"),
new Array("Very high-speed DSL (VDSL)", "52224"),
new Array("OC1", "53248"),
new Array("100 Base-T (fast ethernet)", "102400"),
new Array("ATM", "158720"),
new Array("OC3", "159744"),
new Array("1000 Base-T", "1024000")
function compute (form, scale)
if (form.size == null form.size.length == 0)
alert("Please enter a valid filesize.");
var size = parseFloat(form.size.value);
for (var i = 1; i <= speeds.length; i++)
var time = size * scale * 8.192 / speeds[i - 1][1];
var hours = Math.floor(time / 3600);
var minutes = Math.floor((time % 3600) / 60);
var seconds = Math.floor(time % 60);
form[i + "hour"].value = hours;
form[i + "minute"].value = minutes;
form[i + "second"].value = seconds;
Example to call above (compute) function
For file Size MB --> compute(30,1024)
For file size KB --> compute(30,1)


Anonymous said...

Hello !.
might , perhaps very interested to know how one can manage to receive high yields .
There is no initial capital needed You may begin to receive yields with as small sum of money as 20-100 dollars.

AimTrust is what you haven`t ever dreamt of such a chance to become rich
The firm represents an offshore structure with advanced asset management technologies in production and delivery of pipes for oil and gas.

It is based in Panama with structures around the world.
Do you want to become really rich in short time?
That`s your chance That`s what you really need!

I feel good, I began to take up real money with the help of this company,
and I invite you to do the same. If it gets down to select a proper companion who uses your money in a right way - that`s the AimTrust!.
I earn US$2,000 per day, and my first deposit was 1 grand only!
It`s easy to get involved , just click this link
and go! Let`s take this option together to become rich

Anonymous said...

Hi Can you please tell me how to check internet download - uplaod speed???

Anonymous said...

You may probably be very interested to know how one can make real money on investments.
There is no need to invest much at first.
You may begin earning with a sum that usually is spent
for daily food, that's 20-100 dollars.
I have been participating in one company's work for several years,
and I'm ready to share my secrets at my blog.

Please visit blog and send me private message to get the info.

P.S. I earn 1000-2000 per day now. [url=]Online Investment Blog[/url]

Anonymous said...

Glad to materialize here. Good day or night everybody!

Let me introduce myself,
my name is Peter.
Generally I’m a social gmabler. recently I take a great interest in online-casino and poker.
Not long time ago I started my own blog, where I describe my virtual adventures.
Probably, it will be interesting for you to utilize special software facilitating winnings .
Please visit my blog. I’ll be glad would you find time to leave your comments.