public void GeoCoder_PerfsTestsUsingMatchedNamesCache() { const string dbLocation1 = @"TestGeoLocationTool.sdf"; connection = DBHelper.GetDbConnection(dbLocation1); GeoCoder geoCoder = new GeoCoder(connection); geoCoder.LoadGazetteerFile(@"TestGaz1.csv"); Stopwatch watch = new Stopwatch(); geoCoder.SetGazetteerColumns( new GazetteerColumnHeaders { Level1Code = "ID_1", Level2Code = "ID_2", Level3Code = "ID_3", Level1Name = "NAME_1", Level2Name = "NAME_2", Level3Name = "NAME_3" }, false); foreach ( string inputFile in new[] { @"TestInput1000.csv", @"TestInput10000.csv", @"TestInput50000.csv" }) { geoCoder.LoadInputFileCsv(inputFile); geoCoder.SetInputColumns(geoCoder.DefaultInputColumnHeaders()); // use cache watch.Restart(); InputData.UseMatchedNamesCache = true; geoCoder.AddAllLocationCodes(); var elapsed = watch.Elapsed.TotalSeconds; // don't use cache geoCoder.LoadInputFileCsv(inputFile); geoCoder.SetInputColumns(geoCoder.DefaultInputColumnHeaders()); watch.Restart(); InputData.UseMatchedNamesCache = false; geoCoder.AddAllLocationCodes(); Debug.WriteLine( "input file: " + inputFile + " cached: " + elapsed + " vs " + "non cached: " + watch.Elapsed.TotalSeconds); } // Example results // input file: TestInput1000.csv cached: 0.0089728 vs non cached: 0.3835499 // input file: TestInput10000.csv cached: 0.073879 vs non cached: 2.8980328 // input file: TestInput50000.csv cached: 0.3852506 vs non cached: 14.464649 }
public void GeoCoder_PerfsTestsUsingDictionaries() { connection = DBHelper.GetDbConnection(dbLocation); connection.InitializeDB(); GeoCoder geoCoder = new GeoCoder(connection); geoCoder.LoadGazetteerFile(@"PHL_adm3.csv"); //You need to copy this file manually Stopwatch watch = new Stopwatch(); watch.Start(); geoCoder.SetGazetteerColumns( new GazetteerColumnHeaders { Level1Code = "ID_1", Level2Code = "ID_2", Level3Code = "ID_3", Level1Name = "NAME_1", Level2Name = "NAME_2", Level3Name = "NAME_3" }, false); Debug.WriteLine("Time to create dictionaries: " + watch.Elapsed.TotalSeconds); foreach (int linesCount in new[] { 500, 1000, 2000 }) { geoCoder.LoadInputFileCsv(GenerateInputFile(linesCount)); geoCoder.SetInputColumns(geoCoder.DefaultInputColumnHeaders()); watch.Restart(); geoCoder.AddAllLocationCodes(); var elapsed = watch.Elapsed.TotalSeconds; //LocationCodes.useDictionaries = !LocationCodes.useDictionaries; geoCoder.LoadInputFileCsv(GenerateInputFile(linesCount)); geoCoder.SetInputColumns(geoCoder.DefaultInputColumnHeaders()); watch.Restart(); geoCoder.AddAllLocationCodes(); Debug.WriteLine( linesCount + " input lines: " + elapsed + " vs " + watch.Elapsed.TotalSeconds); // LocationCodes.useDictionaries = !LocationCodes.useDictionaries; foreach (var row in geoCoder.InputData.AsEnumerable()) { var elems = row.ItemArray; Assert.IsFalse(elems[5] is DBNull); Assert.IsFalse(elems[6] is DBNull); Assert.IsFalse(elems[7] is DBNull); } } }
public void GeoCoderCodeAll_PerfsTests_TimeToCodeAll() { const string dbLocation1 = @"TestGeoLocationTool.sdf"; connection = DBHelper.GetDbConnection(dbLocation1); GeoCoder geoCoder = new GeoCoder(connection); geoCoder.LoadGazetteerFile(@"TestGaz1.csv"); Stopwatch watch = new Stopwatch(); geoCoder.SetGazetteerColumns( new GazetteerColumnHeaders { Level1Code = "ID_1", Level2Code = "ID_2", Level3Code = "ID_3", Level1Name = "NAME_1", Level2Name = "NAME_2", Level3Name = "NAME_3", Level1AltName = "VARNAME_1", Level2AltName = "VARNAME_2", Level3AltName = "VARNAME_3" }, false); geoCoder.LoadInputFileCsv("TestInput1.csv"); geoCoder.SetInputColumns(geoCoder.DefaultInputColumnHeaders()); watch.Start(); geoCoder.AddAllLocationCodes(); Debug.WriteLine( geoCoder.InputData.Rows.Count + " input lines: " + watch.Elapsed.TotalSeconds); // Example results // 25 input lines: 0.072016 }