public void RunPerfTests() { string[] files = Directory.GetFiles(@"c:\temp\trash", "*.htm", SearchOption.AllDirectories); System.Diagnostics.Stopwatch sw; for (int i = 0; i < 10; i++) { //HTML Parser sw = new System.Diagnostics.Stopwatch(); sw.Start(); foreach (string file in files) { new HtmlLightDocument(File.ReadAllText(file)); } Console.WriteLine("HTML = {0}", sw.ElapsedMilliseconds); //XML Parser sw = new System.Diagnostics.Stopwatch(); sw.Start(); foreach (string file in files) { new XmlLightDocument(File.ReadAllText(file)); } Console.WriteLine("XHTM = {0}", sw.ElapsedMilliseconds); //Parse Only sw = new System.Diagnostics.Stopwatch(); sw.Start(); IXmlLightReader rdr = new EmptyReader(); foreach (string file in files) { XmlLightParser.Parse(File.ReadAllText(file), XmlLightParser.AttributeFormat.Xml, rdr); } Console.WriteLine("NDOM = {0}", sw.ElapsedMilliseconds); //Text Only sw = new System.Diagnostics.Stopwatch(); sw.Start(); foreach (string file in files) { XmlLightParser.ParseText(File.ReadAllText(file)); } Console.WriteLine("TEXT = {0}", sw.ElapsedMilliseconds); } }
public void TestParseText() { string text = Normalize(XmlLightParser.ParseText(document)); Assert.AreEqual("Document Title this is > cdata! Hi, this is content.", text); }