diff --git a/DevPack.Benchmarks/DevPack.Benchmarks.csproj b/DevPack.Benchmarks/DevPack.Benchmarks.csproj new file mode 100644 index 00000000..fc7af6ad --- /dev/null +++ b/DevPack.Benchmarks/DevPack.Benchmarks.csproj @@ -0,0 +1,19 @@ + + + net48 + Exe + latest + enable + enable + Skyline.DataMiner.Dev.Utils.Solutions.MediaOps.Plan.Benchmarks + Skyline.DataMiner.Solutions.MediaOps.Plan.Benchmarks + false + + + + + + + + + diff --git a/DevPack.Benchmarks/Program.cs b/DevPack.Benchmarks/Program.cs new file mode 100644 index 00000000..ba39991c --- /dev/null +++ b/DevPack.Benchmarks/Program.cs @@ -0,0 +1,12 @@ +namespace Skyline.DataMiner.Solutions.MediaOps.Plan.Benchmarks +{ + using BenchmarkDotNet.Running; + + internal static class Program + { + private static void Main(string[] args) + { + BenchmarkSwitcher.FromAssembly(typeof(Program).Assembly).Run(args); + } + } +} diff --git a/DevPack.Benchmarks/Workflow/Jobs/ReadJobsWithinTimespanBenchmarks.cs b/DevPack.Benchmarks/Workflow/Jobs/ReadJobsWithinTimespanBenchmarks.cs new file mode 100644 index 00000000..64571594 --- /dev/null +++ b/DevPack.Benchmarks/Workflow/Jobs/ReadJobsWithinTimespanBenchmarks.cs @@ -0,0 +1,82 @@ +namespace Skyline.DataMiner.Solutions.MediaOps.Plan.Benchmarks.Workflow.Jobs +{ + using System; + using System.Linq; + + using BenchmarkDotNet.Attributes; + + using Skyline.DataMiner.Net; + using Skyline.DataMiner.Net.Apps.DataMinerObjectModel; + using Skyline.DataMiner.Net.Messages.SLDataGateway; + using Skyline.DataMiner.Solutions.MediaOps.Plan.API; + using Skyline.DataMiner.Solutions.MediaOps.Plan.Storage.DOM.SlcWorkflow; + using Skyline.DataMiner.Solutions.MediaOps.Plan.UnitTesting.Simulation; + + [MemoryDiagnoser] + [InProcess] + public class ReadJobsWithinTimespanBenchmarks + { + private static readonly DateTime SeedStartUtc = new DateTime(2026, 01, 01, 00, 00, 00, DateTimeKind.Utc); + private static readonly DateTime BenchmarkWindowStartUtc = SeedStartUtc.AddDays(10); + + private IConnection? connection; + private MediaOpsPlanApi? api; + private FilterElement? timespanFilter; + + [Params(1, 24, 168)] + public int TimespanHours { get; set; } + + [GlobalSetup] + public void GlobalSetup() + { + var dms = MediaOpsPlanSimulation.Create(); + connection = dms.CreateConnection(); + api = (MediaOpsPlanApi)(connection.GetMediaOpsPlanApi() ?? throw new InvalidOperationException("Unable to create MediaOpsPlanApi")); + + SeedJobs(); + + var windowEndUtc = BenchmarkWindowStartUtc.AddHours(TimespanHours); + timespanFilter = new ANDFilterElement( + DomInstanceExposers.DomDefinitionId.Equal(SlcWorkflowIds.Definitions.Jobs.Id), + DomInstanceExposers.FieldValues.DomInstanceField(SlcWorkflowIds.Sections.JobInfo.JobStart).GreaterThanOrEqual(BenchmarkWindowStartUtc), + DomInstanceExposers.FieldValues.DomInstanceField(SlcWorkflowIds.Sections.JobInfo.JobEnd).LessThanOrEqual(windowEndUtc)); + } + + [Benchmark(Description = "Read all jobs within a timespan")] + public Job[] ReadAllJobsWithinTimespan() + { + return api!.DomHelpers.SlcWorkflowHelper + .GetJobs(timespanFilter!) + .Select(domJob => new Job(api, domJob)) + .ToArray(); + } + + [GlobalCleanup] + public void GlobalCleanup() + { + connection?.Dispose(); + } + + private void SeedJobs() + { + var jobs = Enumerable.Range(0, 24 * 30) + .Select(index => + { + var start = SeedStartUtc.AddHours(index); + var end = start.AddMinutes(45); + + return new Job + { + Name = $"Benchmark Job {index:D4}", + Start = start, + End = end, + PreRollStart = start, + PostRollEnd = end, + }; + }) + .ToArray(); + + api!.Jobs.Create(jobs); + } + } +} diff --git a/DevPack/Skyline.DataMiner.Dev.Utils.Solutions.MediaOps.Plan.csproj b/DevPack/Skyline.DataMiner.Dev.Utils.Solutions.MediaOps.Plan.csproj index e8d84e6b..11c6a79d 100644 --- a/DevPack/Skyline.DataMiner.Dev.Utils.Solutions.MediaOps.Plan.csproj +++ b/DevPack/Skyline.DataMiner.Dev.Utils.Solutions.MediaOps.Plan.csproj @@ -34,6 +34,7 @@ + diff --git a/MediaOps Plan.slnx b/MediaOps Plan.slnx index 192a2cb5..784ecf91 100644 --- a/MediaOps Plan.slnx +++ b/MediaOps Plan.slnx @@ -12,6 +12,7 @@ +