private int GetLocationsAmmountFromDb() { using (var connection = new SqlConnection(ConfigurationService.GetTestDbConnectionString())) { connection.Open(); using (var command = new SqlCommand(ScriptsService.GetScript("GetLocationsAmmount"), connection)) { return((int)command.ExecuteScalar()); } } }
private static void PrepareTestData() { using (var sqlConnection = new SqlConnection(ConfigurationService.GetTestDbConnectionString())) { sqlConnection.Open(); using (var sqlCommand = new SqlCommand(ScriptsService.GetScript("PrepareTestData"), sqlConnection)) { sqlCommand.CommandTimeout = 60; sqlCommand.ExecuteNonQuery(); } } }
public void SpatialDatabase_PerformanceTest() { using (var connection = new SqlConnection(ConfigurationService.GetTestDbConnectionString())) { connection.Open(); using (var command = new SqlCommand(ScriptsService.GetScript("GetNearestLocations"), connection)) { GC.Collect(); GC.WaitForFullGCComplete(); var watch = new Stopwatch(); watch.Start(); for (int i = 0; i < 100; i++) { command.ExecuteReader().Close(); } watch.Stop(); Trace.WriteLine(string.Format("SQL Server - For {0} spatial points it took {1} ms to found {2} nearest points", GetLocationsAmmountFromDb(), watch.ElapsedMilliseconds / 100, 5)); } } }