85 lines
3.2 KiB
C#
85 lines
3.2 KiB
C#
using StellaOps.Bench.LinkNotMerge.Baseline;
|
|
using StellaOps.Bench.LinkNotMerge.Reporting;
|
|
using Xunit;
|
|
|
|
using StellaOps.TestKit;
|
|
namespace StellaOps.Bench.LinkNotMerge.Tests;
|
|
|
|
public sealed class BenchmarkScenarioReportTests
|
|
{
|
|
[Trait("Category", TestCategories.Unit)]
|
|
[Fact]
|
|
public void RegressionDetection_FlagsBreaches()
|
|
{
|
|
var result = new ScenarioResult(
|
|
Id: "scenario",
|
|
Label: "Scenario",
|
|
Iterations: 3,
|
|
ObservationCount: 1000,
|
|
AliasGroups: 100,
|
|
LinksetCount: 90,
|
|
TotalStatistics: new DurationStatistics(200, 240, 260),
|
|
InsertStatistics: new DurationStatistics(80, 90, 100),
|
|
CorrelationStatistics: new DurationStatistics(120, 150, 170),
|
|
TotalThroughputStatistics: new ThroughputStatistics(8000, 7000),
|
|
InsertThroughputStatistics: new ThroughputStatistics(9000, 8000),
|
|
AllocationStatistics: new AllocationStatistics(120),
|
|
ThresholdMs: null,
|
|
MinThroughputThresholdPerSecond: null,
|
|
MinInsertThroughputThresholdPerSecond: null,
|
|
MaxAllocatedThresholdMb: null);
|
|
|
|
var baseline = new BaselineEntry(
|
|
ScenarioId: "scenario",
|
|
Iterations: 3,
|
|
Observations: 1000,
|
|
Aliases: 100,
|
|
Linksets: 90,
|
|
MeanTotalMs: 150,
|
|
P95TotalMs: 170,
|
|
MaxTotalMs: 180,
|
|
MeanInsertMs: 60,
|
|
MeanCorrelationMs: 90,
|
|
MeanThroughputPerSecond: 9000,
|
|
MinThroughputPerSecond: 8500,
|
|
MeanInsertThroughputPerSecond: 10000,
|
|
MinInsertThroughputPerSecond: 9500,
|
|
MaxAllocatedMb: 100);
|
|
|
|
var report = new BenchmarkScenarioReport(result, baseline, regressionLimit: 1.1);
|
|
|
|
Assert.True(report.DurationRegressionBreached);
|
|
Assert.True(report.ThroughputRegressionBreached);
|
|
Assert.True(report.InsertThroughputRegressionBreached);
|
|
Assert.Contains(report.BuildRegressionFailureMessages(), message => message.Contains("max duration"));
|
|
}
|
|
|
|
[Trait("Category", TestCategories.Unit)]
|
|
[Fact]
|
|
public void RegressionDetection_NoBaseline_NoBreaches()
|
|
{
|
|
var result = new ScenarioResult(
|
|
Id: "scenario",
|
|
Label: "Scenario",
|
|
Iterations: 3,
|
|
ObservationCount: 1000,
|
|
AliasGroups: 100,
|
|
LinksetCount: 90,
|
|
TotalStatistics: new DurationStatistics(200, 220, 230),
|
|
InsertStatistics: new DurationStatistics(90, 100, 110),
|
|
CorrelationStatistics: new DurationStatistics(110, 120, 130),
|
|
TotalThroughputStatistics: new ThroughputStatistics(8000, 7900),
|
|
InsertThroughputStatistics: new ThroughputStatistics(9000, 8900),
|
|
AllocationStatistics: new AllocationStatistics(64),
|
|
ThresholdMs: null,
|
|
MinThroughputThresholdPerSecond: null,
|
|
MinInsertThroughputThresholdPerSecond: null,
|
|
MaxAllocatedThresholdMb: null);
|
|
|
|
var report = new BenchmarkScenarioReport(result, baseline: null, regressionLimit: null);
|
|
|
|
Assert.False(report.RegressionBreached);
|
|
Assert.Empty(report.BuildRegressionFailureMessages());
|
|
}
|
|
}
|