How to calculate download Speed using C#.net and java script 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
Example to call above (compute) function
For file Size MB --> compute(30,1024)
For file size KB --> compute(30,1)
No comments:
Post a Comment