public void RunCfgBenchmark() { var xml = File.ReadAllText(@"NorthWind.xml"); var xDocWatch = new Stopwatch(); var procWatch = new Stopwatch(); var cfgWatch = new Stopwatch(); xDocWatch.Start(); var xDocProcess = XDocument.Parse(xml).Root.Element("processes").Element("add"); xDocWatch.Stop(); cfgWatch.Start(); var cfgProcess = new ConfigurationFactory(xml, new TestLogger()).CreateSingle(); cfgWatch.Stop(); procWatch.Start(); var bigBloatedProcess = ProcessFactory.CreateSingle(xml, new TestLogger()); procWatch.Stop(); Console.WriteLine("Process: " + procWatch.ElapsedMilliseconds); // ~ 1928 to 1586 Console.WriteLine("Config: " + cfgWatch.ElapsedMilliseconds); // ~ 341 to 222 Console.WriteLine("XDocument: " + xDocWatch.ElapsedMilliseconds); // ~ 45ms to 44 Assert.AreEqual("NorthWind", xDocProcess.Attribute("name").Value); Assert.AreEqual("NorthWind", cfgProcess.Name); Assert.AreEqual("NorthWind", bigBloatedProcess.Name); }
public Result Import(string file, decimal sample = 100m) { var fileInspection = new ConfigurationFactory("DataProfiler").CreateSingle().FileInspection.GetInspectionRequest(); fileInspection.Sample = sample > 0m || sample < 100m ? sample : fileInspection.Sample; var response = new FileImporter().Import( new FileInfo(file), fileInspection, new ConnectionConfigurationElement() { Name = "output", Provider = "internal" } ); var result = new Result { Fields = response.Information.Fields, Rows = response.Rows, Provider = "file" }; result.Properties["filename"] = response.Information.FileInfo.FullName; result.Properties["delimiter"] = response.Information.Delimiter.ToString(CultureInfo.InvariantCulture); return result; }