Harden proxy permissions and cache behavior, streamline metadata fetching, remove obsolete rules, and validate the stable SDK with expanded regression coverage. Document backup format changes.
34 lines
1.5 KiB
C#
34 lines
1.5 KiB
C#
using System.Diagnostics;
|
|
using Jellyfin.Plugin.Multilang.Data;
|
|
using Jellyfin.Plugin.Multilang.Services.Refresh;
|
|
using Xunit.Abstractions;
|
|
|
|
namespace Jellyfin.Plugin.Multilang.Tests;
|
|
|
|
public sealed class TranslationStoreBatchTests(ITestOutputHelper output)
|
|
{
|
|
[Fact]
|
|
public void BatchFactsLookupMatchesIndividualReads()
|
|
{
|
|
var root = TestPaths.CreateRoot();
|
|
try
|
|
{
|
|
var store = new TranslationStore(new TestApplicationPaths(root));
|
|
var ids = Enumerable.Range(0, 100).Select(index => index.ToString()).ToArray();
|
|
foreach (var id in ids)
|
|
store.SaveMetadata(new(id, id, "movie", RefreshWorkClass.Movies, 0, 0, null, "Movie"), "fi",
|
|
new("Title", "Overview", "Tagline", "Title", "fi", [], [], [], []), new("scope", 1, true), true);
|
|
var timer = Stopwatch.StartNew();
|
|
var individual = ids.Select(id => store.GetFacts(id)!).ToArray();
|
|
var separateMs = timer.Elapsed.TotalMilliseconds;
|
|
timer.Restart();
|
|
var batch = store.GetFactsForItems(ids.Concat(ids));
|
|
var batchMs = timer.Elapsed.TotalMilliseconds;
|
|
Assert.Equal(individual, ids.Select(id => batch[id]));
|
|
Assert.Equal(ids.Length, batch.Count);
|
|
output.WriteLine($"100 individual fact reads: {separateMs:F2} ms; one batched read: {batchMs:F2} ms. Timing is diagnostic, not a pass condition.");
|
|
}
|
|
finally { TestPaths.DeleteRoot(root); }
|
|
}
|
|
}
|