public CMapTileList(CStartParameters aStartParameters) { Int64 total_number_tiles = (aStartParameters.x_max - aStartParameters.x_min) / 250 * (aStartParameters.y_max - aStartParameters.y_min) / 250; Int64 number_of_tiles_created = 0; theMapList = new List <CMapTile>(); // for (Int64 x = 236000; x < 6076000;x=x+250) for (Int64 x = aStartParameters.x_min; x < aStartParameters.x_max; x = x + 250) { for (Int64 y = aStartParameters.y_min; y < aStartParameters.y_max; y = y + 250) { CMapTile aChapTile = new CMapTile(x, y); theMapList.Add(aChapTile); number_of_tiles_created++; if (number_of_tiles_created % 100 == 0 && number_of_tiles_created != 0) { Console.Write("\r{0} {1}", number_of_tiles_created, " The target number is " + total_number_tiles); } } } Console.WriteLine("\r " + total_number_tiles + " tiles were created "); }
public static void readListToFileToDiskBinary(Stopwatch sw, string pathToFile, CStartParameters aStartParameters) { CMapTileList aMapaMapTileList = null; using (FileStream fs = new FileStream(pathToFile, FileMode.Open)) using (var memoryStream = new MemoryStream()) { sw.Start(); fs.CopyTo(memoryStream); sw.Stop(); memoryStream.Seek(0, SeekOrigin.Begin); IFormatter formatter = new BinaryFormatter(); aMapaMapTileList = (CMapTileList)formatter.Deserialize(memoryStream); } if (aStartParameters.removeTestFile_DatabaseAfterTest) { File.Delete(pathToFile); } }
static void Main(string[] args) { Stopwatch sw = new Stopwatch(); // Read start parameter file CStartParameters aStartParColl = new CStartParameters("StartParamsPiposBenchmark.txt"); //construct testdata Console.WriteLine("Starts performance test"); Console.WriteLine("Creates testtiles"); sw.Start(); CMapTileList aMaptileList = new CMapTileList(aStartParColl); sw.Stop(); Console.WriteLine("It took {0} to create testdata", sw.Elapsed); Console.WriteLine(); sw.Reset(); //Test disk performace // 10 possible test slots Console.WriteLine(); Console.WriteLine("Test performace of diskconnection."); for (int i = 0; i < 10; i++) { if (aStartParColl.targetFolders[i] != null) { CMapTileList.writeListToFileToDiskBinary(sw, aStartParColl.targetFolders[i], aMaptileList); Console.WriteLine("{0} Write Timemeasure={1}", aStartParColl.targetFoldersName[i], sw.Elapsed); sw.Reset(); FileInfo fi = new FileInfo(aStartParColl.targetFolders[i]); Console.WriteLine("File Size in Megabytes: {0}", ((Int64)(fi.Length / 1024f) / 1024f)); CMapTileList.readListToFileToDiskBinary(sw, aStartParColl.targetFolders[i], aStartParColl); Console.WriteLine("{0} Read Timemeasure={1}", aStartParColl.targetFoldersName[i], sw.Elapsed); Console.WriteLine(); sw.Reset(); } } //Test database performace // 10 possible test slots Console.WriteLine("Test performace of databaseconnection."); for (int i = 0; i < 10; i++) { if (aStartParColl.connectStrings[i] != null) { sw.Start(); aMaptileList.writeListToDatabase(aStartParColl.connectStrings[i]); sw.Stop(); Console.WriteLine("{0} Write Timemeasure={1}", aStartParColl.connectStringsName[i], sw.Elapsed); sw.Reset(); CMapTileList.GetSizeOfTable(aStartParColl.connectStrings[i]); sw.Start(); aMaptileList.readListFromDatabase(aStartParColl.connectStrings[i]); sw.Stop(); Console.WriteLine("{0} Read Timemeasure={1}", aStartParColl.connectStringsName[i], sw.Elapsed); Console.WriteLine(); sw.Reset(); } } Console.WriteLine(); Console.WriteLine("Done! Press any key to close."); Console.ReadKey(); }