|
1 | 1 | using BenchmarkDotNet.Attributes; |
2 | 2 | using ModularityKit.Mutator.Abstractions.Audit; |
| 3 | +using ModularityKit.Mutator.Abstractions.Context; |
| 4 | +using ModularityKit.Mutator.Abstractions.Effects; |
3 | 5 | using ModularityKit.Mutator.Abstractions.History; |
| 6 | +using ModularityKit.Mutator.Abstractions.Intent; |
4 | 7 | using ModularityKit.Mutator.Abstractions.Results; |
5 | 8 | using ModularityKit.Mutator.Benchmarks.Results.Support; |
6 | 9 |
|
7 | 10 | namespace ModularityKit.Mutator.Benchmarks.Results; |
8 | 11 |
|
9 | | -/// <summary> |
10 | | -/// Benchmarks materialization of history and audit output from an executed mutation result. |
11 | | -/// </summary> |
12 | 12 | [BenchmarkCategory("Results")] |
13 | 13 | [MemoryDiagnoser] |
14 | 14 | [InProcess] |
15 | 15 | public class MutationOutputMaterializationBenchmarks |
16 | 16 | { |
17 | | - private MutationResult<ResultsBenchmarkSupport.ResultBenchmarkState> _result = null!; |
| 17 | + private MutationResult<ResultsBenchmarkSupport.ResultBenchmarkState> _result = default!; |
18 | 18 | private string _executionId = string.Empty; |
19 | 19 | private TimeSpan _duration; |
| 20 | + private IReadOnlyList<SideEffect> _sideEffectList = null!; |
| 21 | + private MutationIntent _historyIntent = null!; |
| 22 | + private MutationIntent _auditIntent = null!; |
| 23 | + private MutationContext _historyContext = null!; |
| 24 | + private MutationContext _auditContext = null!; |
20 | 25 |
|
21 | | - /// <summary> |
22 | | - /// Prepares a representative executed mutation result for output materialization benchmarks. |
23 | | - /// </summary> |
24 | 26 | [GlobalSetup] |
25 | 27 | public void Setup() |
26 | 28 | { |
27 | 29 | _result = ResultsBenchmarkSupport.CreateExecutedResult(sideEffectCount: 3, changeCount: 4); |
28 | 30 | _executionId = "results-benchmark-execution"; |
29 | 31 | _duration = TimeSpan.FromMilliseconds(2); |
| 32 | + _sideEffectList = _result.SideEffects.ToList(); |
| 33 | + _historyIntent = ResultsBenchmarkSupport.CreateIntent( |
| 34 | + "ResultHistoryMaterialization", |
| 35 | + "Materialize history output for benchmark results."); |
| 36 | + _auditIntent = ResultsBenchmarkSupport.CreateIntent( |
| 37 | + "ResultAuditMaterialization", |
| 38 | + "Materialize audit output for benchmark results."); |
| 39 | + _historyContext = ResultsBenchmarkSupport.CreateContext("history"); |
| 40 | + _auditContext = ResultsBenchmarkSupport.CreateContext("audit"); |
30 | 41 | } |
31 | 42 |
|
32 | | - /// <summary> |
33 | | - /// Measures materialization of the mutation history entry, including change and side effect copying. |
34 | | - /// </summary> |
35 | 43 | [Benchmark(Baseline = true)] |
36 | 44 | public MutationHistoryEntry HistoryEntry_Materialization() |
37 | 45 | { |
38 | 46 | return new MutationHistoryEntry |
39 | 47 | { |
40 | 48 | ExecutionId = _executionId, |
41 | 49 | StateId = ResultsBenchmarkSupport.StateId, |
42 | | - Intent = ResultsBenchmarkSupport.CreateIntent( |
43 | | - "ResultHistoryMaterialization", |
44 | | - "Materialize history output for benchmark results."), |
45 | | - Context = ResultsBenchmarkSupport.CreateContext("history"), |
| 50 | + Intent = _historyIntent, |
| 51 | + Context = _historyContext, |
46 | 52 | Changes = _result.Changes, |
47 | | - SideEffects = _result.SideEffects.ToList(), |
| 53 | + SideEffects = _sideEffectList, |
48 | 54 | Timestamp = DateTimeOffset.UtcNow, |
49 | 55 | ExecutionTime = _duration |
50 | 56 | }; |
51 | 57 | } |
52 | 58 |
|
53 | | - /// <summary> |
54 | | - /// Measures materialization of the audit entry produced from the same executed mutation result. |
55 | | - /// </summary> |
56 | 59 | [Benchmark] |
57 | 60 | public MutationAuditEntry AuditEntry_Materialization() |
58 | 61 | { |
59 | 62 | return new MutationAuditEntry |
60 | 63 | { |
61 | 64 | ExecutionId = _executionId, |
62 | 65 | StateId = ResultsBenchmarkSupport.StateId, |
63 | | - StateType = nameof(ResultsBenchmarkSupport.ResultBenchmarkState), |
64 | | - MutationIntent = ResultsBenchmarkSupport.CreateIntent( |
65 | | - "ResultAuditMaterialization", |
66 | | - "Materialize audit output for benchmark results."), |
67 | | - Context = ResultsBenchmarkSupport.CreateContext("audit"), |
| 66 | + StateType = "ResultBenchmarkState", |
| 67 | + MutationIntent = _auditIntent, |
| 68 | + Context = _auditContext, |
68 | 69 | Changes = _result.Changes, |
69 | 70 | IsSuccess = _result.IsSuccess, |
70 | 71 | ErrorMessage = null, |
|
0 commit comments