Often when building a store and forward SQL Compact mobile application I need to establish early on in the project how long it will take for the device to synchronise with the base SQL Server. Knowing how long syncrhonisation will take over GPRS, or WIFI can be one of the main go/no go points of whether a SQL Compact solution is best.
So I came up with this simple way to establish the initial syncrhonisation time to fully populate the mobile database. Obviously this calculation is based on the bandwidth we have available.
This is what I came up with, give it the path to an SDF SQL Compact database and off you go -
public string SyncTimes(string strfileofsdffile)
{
FileInfo f = new FileInfo(strfileofsdffile);
long bits= f.Length*8;
decimal elevenb = Math.Round((decimal) (bits / 11000000),1); // 11mbs
decimal gprs = Math.Round((decimal)(bits / 80000), 1); // 8kbs
decimal hsdpa = Math.Round((decimal)(bits / 3600000), 1); // 3.6mbs
return "802.11b (11Mbs)=" + timelabel(elevenb) + ",GPRS/2G (8Kkbs)=" + timelabel(gprs) + ",HSDPA/3.5G (3.6mbs)=" + timelabel(hsdpa);
}
private string timelabel(decimal seconds)
{
string ret = ""
decimal decseconds = seconds;
if (decseconds < 60)
{
ret += decseconds + " seconds"
}
else
{
decimal decminutes = Math.Round(decseconds / 60);
decseconds = (decminutes * 60)-seconds;
ret += decminutes.ToString("00")+":"+decseconds.ToString("00");
}
return ret;
}
Obviously this is only serves as a guide to show the initial syncrhonisation and subsequent syncs. will just be transmission of any data changes. However I find it invaluable to just get a feel of how long it till take to get started.
Technorati tags:
SQL Compact