Skip to content

Commit

Permalink
Remove fizzler & HAP deps from Test project; add AngleSharp to perf t…
Browse files Browse the repository at this point in the history
…ests
  • Loading branch information
jamietre committed Aug 22, 2014
1 parent aba9f82 commit 56c6cea
Show file tree
Hide file tree
Showing 8 changed files with 57 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>CsQuery.PerformanceTests</RootNamespace>
<AssemblyName>CsQuery.PerformanceTests</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
<IsWebBootstrapper>false</IsWebBootstrapper>
Expand Down Expand Up @@ -39,6 +39,7 @@
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
Expand All @@ -47,11 +48,15 @@
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup>
<StartupObject />
</PropertyGroup>
<ItemGroup>
<Reference Include="AngleSharp">
<HintPath>..\packages\AngleSharp.0.6.1\lib\portable-win+net45+wp80\AngleSharp.dll</HintPath>
</Reference>
<Reference Include="Fizzler">
<HintPath>..\packages\Fizzler.0.9.3\lib\net35\Fizzler.dll</HintPath>
</Reference>
Expand Down Expand Up @@ -85,12 +90,8 @@
<ItemGroup>
<None Include="app.config" />
<None Include="packages.config" />
<None Include="Performance\Output\perftest_2012_7_27_55047.csv" />
<None Include="Performance\Output\perftest_latest.csv" />
</ItemGroup>
<ItemGroup>
<Content Include="Performance\Output\perftest_2012_7_27_55047.txt" />
<Content Include="Performance\Output\perftest_latest.txt" />
<Content Include="Resources\HTML Standard.htm">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
Expand Down Expand Up @@ -129,6 +130,9 @@
<Name>CsQuery</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Folder Include="Performance\Output\" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(SolutionDir)\.nuget\nuget.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
using CsQuery.Engine;
using CsQuery.HtmlParser;
using CsQuery.ExtensionMethods.Internal;
using AngleSharp.DOM;

namespace CsQuery.PerformanceTests
{
Expand All @@ -23,6 +24,7 @@ public class PerfCompare
public CQ CsqueryDocument_Simple { get; set; }
public CQ CsqueryDocument_Ranged { get; set; }
public CQ CsqueryDocument_NoIndex { get; set; }
public IDocument AngleSharpDocument { get; set; }
public HtmlDocument HapDocument { get; set; }
public TimeSpan MaxTestTime { get; set; }

Expand Down Expand Up @@ -60,6 +62,8 @@ public void LoadBoth(string doc)

HapDocument = new HtmlDocument();
HapDocument.LoadHtml(html);

AngleSharpDocument = AngleSharp.DocumentBuilder.Html(html);
}

public PerfComparison Compare(string selector, string xpath)
Expand All @@ -73,6 +77,13 @@ public PerfComparison Compare(string selector, string xpath)
}
catch { }

int angleSharpCount = 0;
try
{
angleSharpCount = AngleSharpDocument.QuerySelectorAll(selector).Count();
}
catch { }

string description = String.Format("Selector returning {0} elements.", cqCount);

bool same = true;
Expand All @@ -81,6 +92,13 @@ public PerfComparison Compare(string selector, string xpath)
description += String.Format(" NOTE: HAP returned {0} elements", hapCount);
same = false;
}
if (angleSharpCount != cqCount)
{
description += String.Format(" NOTE: AngleSharp returned {0} elements", angleSharpCount);
same = false;
}



// use Count() for both to ensure that all results are retrieved (e.g. if the engine is lazy)

Expand Down Expand Up @@ -111,6 +129,10 @@ public PerfComparison Compare(string selector, string xpath)
var hapLength = HapDocument.DocumentNode.SelectNodes(xpath).OrDefault().ToList();
});

Action angle = new Action(() =>
{
var angleSharpLength = AngleSharpDocument.QuerySelectorAll(selector).ToList();
});

IDictionary<string, Action> actions = new Dictionary<string, Action>();
if (Program.IncludeTests.HasFlag(TestMethods.CsQuery_NoIndex))
Expand All @@ -133,6 +155,10 @@ public PerfComparison Compare(string selector, string xpath)
{
actions.Add("Fizzler", fiz);
}
if (Program.IncludeTests.HasFlag(TestMethods.AngleSharp))
{
actions.Add("AngleSharp", angle);
}
var results = Compare(actions, testName, description);
results.SameResults = same;
results.Context = Context;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
using CsQuery.Implementation;
using CsQuery.HtmlParser;
using CsQuery.ExtensionMethods.Internal;
using AngleSharp.DOM;

namespace CsQuery.PerformanceTests.Tests
{
Expand Down Expand Up @@ -90,6 +91,12 @@ public void LoadingDom()
hapDoc.LoadHtml(html);
});

Action angleSharp = new Action(() =>
{
var angleSharpDocument = AngleSharp.DocumentBuilder.Html(html);
});


IDictionary<string,Action> tests = new Dictionary<string,Action>();

if (Program.IncludeTests.HasFlag(TestMethods.CsQuery_NoIndex)) {
Expand All @@ -106,6 +113,12 @@ public void LoadingDom()
{
tests.Add("HAP", hap);
}

if (Program.IncludeTests.HasFlag(TestMethods.AngleSharp))
{
tests.Add("AngleSharp", angleSharp);
}

Compare(tests, "Create DOM from html");

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ public enum TestMethods
CsQuery_SimpleIndex = 2,
CsQuery_RangedIndex = 4,
HAP = 8,
Fizzler=16
Fizzler=16,
AngleSharp=32
}

public class Program
Expand All @@ -33,7 +34,8 @@ public static TestMethods IncludeTests
TestMethods.CsQuery_NoIndex |
TestMethods.CsQuery_SimpleIndex |
TestMethods.Fizzler |
TestMethods.HAP;
TestMethods.HAP |
TestMethods.AngleSharp;
}
}
public static string OutputDirectory;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0"?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.3.0.0" newVersion="1.3.0.0" />
<assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-1.3.0.0" newVersion="1.3.0.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/></startup></configuration>
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="AngleSharp" version="0.6.1" targetFramework="net45" />
<package id="Fizzler" version="0.9.3" targetFramework="net40" />
<package id="HtmlAgilityPack" version="1.4.6" targetFramework="net40" />
</packages>
15 changes: 0 additions & 15 deletions source/CsQuery.Tests/Csquery.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -61,21 +61,6 @@
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="Fizzler, Version=0.1.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Fizzler.0.9.3\lib\net35\Fizzler.dll</HintPath>
</Reference>
<Reference Include="Fizzler.Sandbox">
<HintPath>..\packages\Fizzler.0.9.3\lib\net35\Fizzler.Sandbox.dll</HintPath>
</Reference>
<Reference Include="Fizzler.Systems.HtmlAgilityPack, Version=0.1.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Fizzler.0.9.3\lib\net35\Fizzler.Systems.HtmlAgilityPack.dll</HintPath>
</Reference>
<Reference Include="HtmlAgilityPack, Version=1.4.6.0, Culture=neutral, PublicKeyToken=bd319b19eaf3b43a, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\HtmlAgilityPack.1.4.6\lib\Net40\HtmlAgilityPack.dll</HintPath>
</Reference>
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
<Reference Include="nunit.framework, Version=2.6.1.12217, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
Expand Down
1 change: 0 additions & 1 deletion source/CsQuery.Tests/Miscellaneous/Miscellaneous.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
using TestContext = Microsoft.VisualStudio.TestTools.UnitTesting.TestContext;
using CsQuery;
using CsQuery.Utility;
using HtmlAgilityPack;

namespace CsQuery.Tests.Miscellaneous
{
Expand Down

0 comments on commit 56c6cea

Please sign in to comment.