Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,13 @@ private static string FindCorpusDirectory()
var directory = new DirectoryInfo(AppContext.BaseDirectory);
while (directory is not null)
{
var candidate = Path.Combine(directory.FullName, "tests", "AngleSharp.ReadOnlyDom.Tests", "temp");
var candidate = Path.Combine(
directory.FullName,
"tests",
"AngleSharp.ReadOnlyDom.Tests",
"TestData",
"corpus"
);
if (Directory.Exists(candidate))
{
return candidate;
Expand All @@ -61,7 +67,7 @@ private static string FindCorpusDirectory()
}

throw new DirectoryNotFoundException(
"Could not locate the checked-in tests/AngleSharp.ReadOnlyDom.Tests/temp corpus."
"Could not locate the checked-in tests/AngleSharp.ReadOnlyDom.Tests/TestData/corpus directory."
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ public static int Run()
Directory.CreateDirectory(directory);
var failures = 0;
long totalBytes = 0;
foreach (var document in BenchmarkCorpus.Load("full"))
var documents = BenchmarkCorpus.Load("full");
foreach (var document in documents)
{
var utf8 = Encoding.UTF8.GetBytes(document.Html);
totalBytes += utf8.Length;
Expand Down Expand Up @@ -48,7 +49,7 @@ public static int Run()
Console.WriteLine($"FAIL {document.Name}: {difference}");
}
}
Console.WriteLine($"Checked 47 documents / {totalBytes:N0} UTF-8 bytes; failures: {failures}.");
Console.WriteLine($"Checked {documents.Count} documents / {totalBytes:N0} UTF-8 bytes; failures: {failures}.");
Console.WriteLine($"Traces: {directory}");
return failures == 0 ? 0 : 1;
}
Expand Down
2 changes: 1 addition & 1 deletion docs/BENCHMARKING.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ and be removed after the decision.

## Workload notes

`CorpusBenchmark` uses checked-in snapshots under `tests/AngleSharp.ReadOnlyDom.Tests/temp`. `small` selects five
`CorpusBenchmark` uses checked-in snapshots under `tests/AngleSharp.ReadOnlyDom.Tests/TestData/corpus`. `small` selects five
representative pages; `full` runs the complete corpus.

`LongSyntheticConstructionBenchmark` generates a deterministic 1.96 MB page with 5,000 irrelevant attribute-heavy
Expand Down
2 changes: 1 addition & 1 deletion scripts/bench-ab-corpus.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ $root = Split-Path -Parent $PSScriptRoot
if (-not $CandidateDll) {
$CandidateDll = Join-Path $root "benchmarks/ProductComparison/AngleSharp.NativeConsole/bin/Release/net10.0/AngleSharp.NativeConsole.dll"
}
$corpDir = Join-Path $root "tests/AngleSharp.ReadOnlyDom.Tests/temp"
$corpDir = Join-Path $root "tests/AngleSharp.ReadOnlyDom.Tests/TestData/corpus"
if (-not $ResultsFile) {
$timestamp = Get-Date -Format "yyyyMMdd-HHmmss"
$ResultsFile = Join-Path $root "artifacts/benchmarks/$timestamp-ab-corpus/results.jsonl"
Expand Down
2 changes: 1 addition & 1 deletion scripts/bench-ab.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ $ErrorActionPreference = "Stop"
$culture = [Globalization.CultureInfo]::InvariantCulture
$root = Split-Path -Parent $PSScriptRoot
$angleProject = Join-Path $root "benchmarks/ProductComparison/AngleSharp.NativeConsole/AngleSharp.NativeConsole.csproj"
$corpusPath = Join-Path $root "tests/AngleSharp.ReadOnlyDom.Tests/temp/$Corpus"
$corpusPath = Join-Path $root "tests/AngleSharp.ReadOnlyDom.Tests/TestData/corpus/$Corpus"
if (-not (Test-Path $corpusPath)) { throw "Missing corpus: $corpusPath" }
if (-not (Test-Path $BaselineDll)) { throw "Missing baseline console: $BaselineDll" }

Expand Down
4 changes: 2 additions & 2 deletions scripts/bench-cross-engine-corpus.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
codeproject) each contain one <a href> inside a <noscript> element, which this engine
extracts and lol-html does not: <noscript> is raw text only with scripting enabled, and
lol-html hardcodes that while this engine follows the scripting-disabled default. Over
47 documents a throwing guard just aborts the run, so those rows are marked instead and
a full-corpus run a throwing guard just aborts the run, so those rows are marked instead and
left out of every aggregate.
- It runs several independent passes and reports run-to-run drift, because a single pass
cannot distinguish a structural delta from machine state.
Expand Down Expand Up @@ -56,7 +56,7 @@ $ErrorActionPreference = "Stop"
$culture = [Globalization.CultureInfo]::InvariantCulture
$root = Split-Path -Parent $PSScriptRoot
$angleProject = Join-Path $root "benchmarks/ProductComparison/AngleSharp.NativeConsole/AngleSharp.NativeConsole.csproj"
$corpusRoot = Join-Path $root "tests/AngleSharp.ReadOnlyDom.Tests/temp"
$corpusRoot = Join-Path $root "tests/AngleSharp.ReadOnlyDom.Tests/TestData/corpus"
$extension = if ($IsWindows) { ".exe" } else { "" }
$timestamp = Get-Date -Format "yyyyMMdd-HHmmss"
$outputDirectory = Join-Path $root "artifacts/benchmarks/$timestamp-cross-engine-corpus"
Expand Down
2 changes: 1 addition & 1 deletion scripts/bench-native-console.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ $ErrorActionPreference = "Stop"
$root = Split-Path -Parent $PSScriptRoot
$rustManifest = Join-Path $root "benchmarks/ProductComparison/lol-html-server/Cargo.toml"
$angleProject = Join-Path $root "benchmarks/ProductComparison/AngleSharp.NativeConsole/AngleSharp.NativeConsole.csproj"
$corpus = Join-Path $root "tests/AngleSharp.ReadOnlyDom.Tests/temp/qq.html"
$corpus = Join-Path $root "tests/AngleSharp.ReadOnlyDom.Tests/TestData/corpus/qq.html"
$timestamp = Get-Date -Format "yyyyMMdd-HHmmss"
$reportPath = Join-Path $root "artifacts/benchmarks/$timestamp-native-console/report.md"

Expand Down
2 changes: 1 addition & 1 deletion scripts/bench-product.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ $root = Split-Path -Parent $PSScriptRoot
$rustManifest = Join-Path $root "benchmarks/ProductComparison/lol-html-server/Cargo.toml"
$angleProject = Join-Path $root "benchmarks/ProductComparison/AngleSharp.NativeServer/AngleSharp.NativeServer.csproj"
$runnerProject = Join-Path $root "benchmarks/ProductComparison/LoadRunner/LoadRunner.csproj"
$corpus = Join-Path $root "tests/AngleSharp.ReadOnlyDom.Tests/temp/qq.html"
$corpus = Join-Path $root "tests/AngleSharp.ReadOnlyDom.Tests/TestData/corpus/qq.html"
$timestamp = Get-Date -Format "yyyyMMdd-HHmmss"
$output = Join-Path $root "artifacts/benchmarks/$timestamp-product-comparison/report.md"

Expand Down
2 changes: 1 addition & 1 deletion scripts/bench-sweep.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ $ErrorActionPreference = "Stop"
$culture = [Globalization.CultureInfo]::InvariantCulture
$root = Split-Path -Parent $PSScriptRoot
$angleProject = Join-Path $root "benchmarks/ProductComparison/AngleSharp.NativeConsole/AngleSharp.NativeConsole.csproj"
$corpusRoot = Join-Path $root "tests/AngleSharp.ReadOnlyDom.Tests/temp"
$corpusRoot = Join-Path $root "tests/AngleSharp.ReadOnlyDom.Tests/TestData/corpus"
$timestamp = Get-Date -Format "yyyyMMdd-HHmmss"
$reportPath = Join-Path $root "artifacts/benchmarks/$timestamp-sweep/report.md"

Expand Down
5 changes: 2 additions & 3 deletions scripts/bench.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ $metadata = @(
"- Runtime: ``$(dotnet --version)``"
"- GC: Server GC (enforced by the benchmark executable and BenchmarkDotNet job)"
"- Job: BenchmarkDotNet Default, LaunchCount=1, out-of-process (no in-process emit toolchain)"
"- Corpus: checked-in snapshots under tests/AngleSharp.ReadOnlyDom.Tests/temp"
"- Corpus: checked-in snapshots under tests/AngleSharp.ReadOnlyDom.Tests/TestData/corpus"
"- Hardware counters: $hardwareCounterNote"
"- Note: a single launch cannot separate per-process variance from a real effect; allocation results remain the primary micro gate."
)
Expand Down Expand Up @@ -52,6 +52,7 @@ function Invoke-Benchmark([string] $filter, [string] $name, [string] $corpusTier
}
}

if ($HardwareCounters) { $env:AS_BENCH_HARDWARE_COUNTERS = "1" }
if ($Tier -in @("compact", "all")) {
Invoke-Benchmark "*CompactBuildBenchmark*" "compact"
}
Expand All @@ -67,8 +68,6 @@ if ($Tier -in @("long-streaming", "extraction", "scraping", "all")) {
if ($Tier -in @("scraping", "extraction", "all")) {
Invoke-Benchmark "*QqArticleScraperBenchmark*" "qq-scraper"
}
if ($HardwareCounters) { $env:AS_BENCH_HARDWARE_COUNTERS = "1" }

if ($Tier -in @("utf8-baseline", "utf8", "all")) {
Invoke-Benchmark "*Utf8TokenizerBaselineBenchmark*" "utf8-baseline"
dotnet run --project $project -c Release -f net10.0 --no-build -- `
Expand Down
2 changes: 1 addition & 1 deletion scripts/collect-pgo.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ $env:DOTNET_TC_QuickJitForLoops = "1"
$env:DOTNET_JitCollect64BitCounts = "1"
try {
foreach ($corpus in $Corpora) {
$corpusPath = Join-Path $root "tests/AngleSharp.ReadOnlyDom.Tests/temp/$corpus"
$corpusPath = Join-Path $root "tests/AngleSharp.ReadOnlyDom.Tests/TestData/corpus/$corpus"
if (-not (Test-Path $corpusPath)) { throw "Missing corpus: $corpusPath" }
foreach ($workload in $Workloads) {
$stem = "$($corpus -replace '\.html$', '')-$workload"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
</ItemGroup>

<ItemGroup>
<None Update="TestData\html5lib-tokenizer\**\*" CopyToOutputDirectory="PreserveNewest" />
<None Update="temp\*.html" CopyToOutputDirectory="PreserveNewest" />
<None Update="TestData\**\*" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>
</Project>
9 changes: 0 additions & 9 deletions tests/AngleSharp.ReadOnlyDom.Tests/AuxHelpers.cs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ public async Task SlowOutputStopsInputDrainAndResumesWithoutChangingBytes(bool e

var firstRead = await output.Reader.ReadAsync();
await Assert.That(execution.IsCompleted).IsFalse();
await Task.Delay(10);

var received = new ArrayBufferWriter<byte>();
Copy(firstRead.Buffer, received);
Expand Down
2 changes: 1 addition & 1 deletion tests/AngleSharp.ReadOnlyDom.Tests/TestReporting.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ internal static void SuppressFileReportsByDefault()

private static void DefaultToDisabled(string variable)
{
if (Environment.GetEnvironmentVariable(variable).IsNullOrWhiteSpace())
if (String.IsNullOrWhiteSpace(Environment.GetEnvironmentVariable(variable)))
{
Environment.SetEnvironmentVariable(variable, "true");
}
Expand Down
2 changes: 1 addition & 1 deletion tests/AngleSharp.ReadOnlyDom.Tests/TopLevelArenaSmoke.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace AngleSharp.Readonly.Tests;

internal class TopLevelArenaSmoke
{
private static readonly string BaseDir = Path.Combine(AppContext.BaseDirectory, "temp");
private static readonly string BaseDir = Path.Combine(AppContext.BaseDirectory, "TestData", "corpus");

private static readonly ConcurrentDictionary<string, string> FileContents = new();
private static readonly ConcurrentDictionary<string, IHtmlDocument> ParsedMutableDocs = new();
Expand Down
6 changes: 3 additions & 3 deletions tests/AngleSharp.ReadOnlyDom.Tests/TopLevelSmoke.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class TopLevelSmoke
{
const int MaxSize = (512 + 128) * 1024;

private static readonly string BaseDir = Path.Combine(AppContext.BaseDirectory, "temp");
private static readonly string BaseDir = Path.Combine(AppContext.BaseDirectory, "TestData", "corpus");

private static readonly ConcurrentDictionary<string, string> FileContents = new();
private static readonly ConcurrentDictionary<string, IHtmlDocument> ParsedMutableDocs = new();
Expand Down Expand Up @@ -303,7 +303,7 @@ private static IEnumerable<SelectorTestCase> GetTestCases(string file, string ta
};

id =
id.IsNullOrWhiteSpace()
String.IsNullOrWhiteSpace(id)
|| id is "19ee99feeb254bf99a88146643d1afa2" or "19ee99feeb254bf99a88146643d1afa3"
|| HasBadChar(id.AsSpan())
? null
Expand Down Expand Up @@ -468,7 +468,7 @@ private static IEnumerable<SelectorTestCase> DistinctSelectors(IEnumerable<Selec
var doc = ParsedMutableDocs.GetOrAdd(fileName, k => parser().ParseDocument(html));
return doc
.All.Select(it => it.Id)
.Where(id => !id.IsNullOrWhiteSpace() && !HasBadChar(id.AsSpan()))
.Where(id => !String.IsNullOrWhiteSpace(id) && !HasBadChar(id.AsSpan()))
.Distinct()
.Take(75)
.Select(id => (fileName, id!));
Expand Down