How many times have you written the perfect application, you spend hours getting it right, only to be told it is running slow. You have performed all the Performance Tuning, and you still get the users saying it is running slowly.
One issue is with the clients connection speed, they may be over GPRS or a dial up connection. You have no control over the users connections speeds, so to help this out why not check their connection speed and if it is running slow then provide a warning message.
The following code will work out your clients connection speed. The only issue with such code is you have to wait until it is completed before you know the speed. To over come this I use an iFrame on the web page, so to speed of connection is worked out in a separate window to the main application. Meaning the client can continue to work while the calculation is taking place.
int numKB = 512;
int length = 0;
string checklen = "\n";
private double CalculateSpeed()
start = DateTime.Now;
length = checklen.Length;
for (int i = 0; i < numKB; i++)
hfSpeedTest.Value += "".PadRight(1024 – length, "/*\\*") + "\n";
end = DateTime.Now;
duration = (end – start);
double timediff = numKB / duration.TotalSeconds;
double speed = System.Math.Round(timediff, 3);hfSpeedTest.Value =
""; return speed;