Group strategies by base type and rank them by median hold time
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
d2cbab5d4b
commit
cbd9830143
12 files changed
+301
-35
No files matched your search
@@ -1,4 +1,5 @@
|
||||
using Flypaper.Core.Strategies;
|
||||
using Flypaper.Storage.Dashboard;
|
||||
using Flypaper.Web.Components.Shared;
|
||||
using Shouldly;
|
||||
|
||||
@@ -63,4 +64,44 @@ public sealed class StrategyNamesTests
|
||||
StrategyNames.Matching("").ShouldBeEmpty();
|
||||
StrategyNames.Matching("nichts").ShouldBeEmpty();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Groups_variants_by_base_type_and_shows_only_content_differences_as_badges()
|
||||
{
|
||||
StrategyNames.Describe("html-drip 50-500ms 1-1024B").GroupKey.ShouldBe("html-drip");
|
||||
StrategyNames.Describe("html-drip 50-500ms 1-640B").GroupKey.ShouldBe("html-drip");
|
||||
var variant = StrategyNames.Describe("html-drip 5-20ms 1-64B head 1024B repeat");
|
||||
variant.GroupKey.ShouldBe("html-drip head repeat");
|
||||
variant.Badges.ShouldBe(["Schnellstart", "Wiederholer"]);
|
||||
StrategyNames.Describe("maze-drip 50-500ms 1-1024B head 1024B link 160B").Badges.ShouldBe(["Schnellstart"]);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Treats_drip_as_the_old_name_of_the_endless_page()
|
||||
{
|
||||
var info = StrategyNames.Describe("drip");
|
||||
|
||||
info.DisplayName.ShouldBe("Endlose Webseite");
|
||||
info.GroupKey.ShouldBe("html-drip");
|
||||
StrategyNames.Matching("endlose webseite").ShouldBe(["html-drip", "drip"]);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Ranks_groups_by_median_and_sinks_groups_with_few_catches()
|
||||
{
|
||||
var samples = new List<StrategySample>();
|
||||
samples.AddRange(Enumerable.Repeat(new StrategySample("html-drip 50-500ms 1-1024B", 10_000), 3));
|
||||
samples.AddRange(Enumerable.Repeat(new StrategySample("html-drip 50-500ms 1-640B", 20_000), 2));
|
||||
samples.Add(new StrategySample("drip", 1_000_000));
|
||||
samples.AddRange(Enumerable.Repeat(new StrategySample("env-drip 50-500ms 1-1024B", 30_000), 5));
|
||||
samples.Add(new StrategySample("text-drip", 500_000_000));
|
||||
|
||||
var ranked = StrategyNames.Rank(samples, 10);
|
||||
|
||||
ranked.Select(r => r.Key).ShouldBe(["env-drip", "html-drip", "text-drip"]);
|
||||
ranked[0].MedianHold.ShouldBe(TimeSpan.FromSeconds(30));
|
||||
ranked[1].Count.ShouldBe(6);
|
||||
ranked[1].MedianHold.ShouldBe(TimeSpan.FromSeconds(15));
|
||||
ranked[1].HoldTime.ShouldBe(TimeSpan.FromMilliseconds(1_070_000));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user