make thumbnail generating multithread

fix the bug with open video
add class distribution chart
This commit is contained in:
Alex Bezdieniezhnykh
2024-09-25 21:46:07 +03:00
parent 742f1ffee9
commit 22d4493d86
11 changed files with 215 additions and 50 deletions
+46
View File
@@ -0,0 +1,46 @@
using System.Diagnostics;
using Azaion.Annotator.Extensions;
using FluentAssertions;
using Xunit;
using ParallelOptions = Azaion.Annotator.Extensions.ParallelOptions;
namespace Azaion.Annotator.Test;
public class ParallelExtTest
{
[Fact]
public async Task ParallelExtWorksOkTest()
{
var list = Enumerable.Range(0, 10).ToList();
var sw = Stopwatch.StartNew();
await ParallelExt.ForEachAsync(list, async (i, cancellationToken) =>
{
await Task.Delay(TimeSpan.FromSeconds(i), cancellationToken);
}, new ParallelOptions
{
CpuUtilPercent = 100,
ProgressUpdateInterval = 1
});
var elapsed = sw.Elapsed;
elapsed.Should().BeLessThan(TimeSpan.FromSeconds(11));
}
[Fact]
public async Task ParallelLibWorksOkTest()
{
var list = Enumerable.Range(0, 10).ToList();
var sw = Stopwatch.StartNew();
await Parallel.ForEachAsync(list, new System.Threading.Tasks.ParallelOptions
{
MaxDegreeOfParallelism = Environment.ProcessorCount,
}, async (i, cancellationToken) =>
{
await Task.Delay(TimeSpan.FromSeconds(i), cancellationToken);
});
var elapsed = sw.Elapsed;
elapsed.Should().BeLessThan(TimeSpan.FromSeconds(11));
}
}