This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
using System.Diagnostics;
|
||||
using Ludarium.Application;
|
||||
using Ludarium.Domain;
|
||||
|
||||
namespace Ludarium.UnitTests;
|
||||
|
||||
public sealed class ScaleTests
|
||||
{
|
||||
[Theory]
|
||||
[InlineData(10_000)]
|
||||
[InlineData(100_000)]
|
||||
[Trait("Category", "Scale")]
|
||||
public void ClassifierProcessesLargeSyntheticInventoriesWithinBoundedResources(int count)
|
||||
{
|
||||
var allocatedBefore = GC.GetAllocatedBytesForCurrentThread();
|
||||
var stopwatch = Stopwatch.StartNew();
|
||||
var recognized = 0;
|
||||
|
||||
for (var index = 0; index < count; index++)
|
||||
{
|
||||
var platform = index % 2 == 0 ? "nes" : "gba";
|
||||
var extension = platform == "nes" ? "nes" : "gba";
|
||||
ReadOnlySpan<byte> header = platform == "nes"
|
||||
? new byte[] { 0x4e, 0x45, 0x53, 0x1a }
|
||||
: new byte[] { 0, 0, 0, 0, 0x24, 0xff, 0xae, 0x51 };
|
||||
var result = ArtifactAnalysis.Classify($"roms/{platform}/Synthetic-{index:D6}.{extension}",
|
||||
header, platform);
|
||||
if (result.MediaType == MediaType.Rom && result.Platform == platform) recognized++;
|
||||
}
|
||||
|
||||
stopwatch.Stop();
|
||||
var allocated = GC.GetAllocatedBytesForCurrentThread() - allocatedBefore;
|
||||
Assert.Equal(count, recognized);
|
||||
Assert.True(stopwatch.Elapsed < TimeSpan.FromSeconds(30), $"Classification took {stopwatch.Elapsed}.");
|
||||
Assert.True(allocated < 512L * 1024 * 1024, $"Classification allocated {allocated:N0} bytes.");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user