forked from dotnet/BenchmarkDotNet
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add event processor functionality (dotnet#2420)
- Loading branch information
1 parent
ece5ccf
commit ad93765
Showing
11 changed files
with
509 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
97 changes: 97 additions & 0 deletions
97
src/BenchmarkDotNet/EventProcessors/CompositeEventProcessor.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using BenchmarkDotNet.Extensions; | ||
using BenchmarkDotNet.Reports; | ||
using BenchmarkDotNet.Running; | ||
using BenchmarkDotNet.Toolchains.Results; | ||
using BenchmarkDotNet.Validators; | ||
|
||
namespace BenchmarkDotNet.EventProcessors | ||
{ | ||
internal sealed class CompositeEventProcessor : EventProcessor | ||
{ | ||
private readonly HashSet<EventProcessor> eventProcessors; | ||
|
||
public CompositeEventProcessor(BenchmarkRunInfo[] benchmarkRunInfos) | ||
{ | ||
var eventProcessors = new HashSet<EventProcessor>(); | ||
|
||
foreach (var info in benchmarkRunInfos) | ||
eventProcessors.AddRange(info.Config.GetEventProcessors()); | ||
|
||
this.eventProcessors = eventProcessors; | ||
} | ||
|
||
public override void OnStartValidationStage() | ||
{ | ||
foreach (var eventProcessor in eventProcessors) | ||
eventProcessor.OnStartValidationStage(); | ||
} | ||
|
||
public override void OnValidationError(ValidationError validationError) | ||
{ | ||
foreach (var eventProcessor in eventProcessors) | ||
eventProcessor.OnValidationError(validationError); | ||
} | ||
|
||
public override void OnEndValidationStage() | ||
{ | ||
foreach (var eventProcessor in eventProcessors) | ||
eventProcessor.OnEndValidationStage(); | ||
} | ||
|
||
public override void OnStartBuildStage(IReadOnlyList<BuildPartition> partitions) | ||
{ | ||
foreach (var eventProcessor in eventProcessors) | ||
eventProcessor.OnStartBuildStage(partitions); | ||
} | ||
|
||
public override void OnBuildComplete(BuildPartition buildPartition, BuildResult buildResult) | ||
{ | ||
foreach (var eventProcessor in eventProcessors) | ||
eventProcessor.OnBuildComplete(buildPartition, buildResult); | ||
} | ||
|
||
public override void OnEndBuildStage() | ||
{ | ||
foreach (var eventProcessor in eventProcessors) | ||
eventProcessor.OnEndBuildStage(); | ||
} | ||
|
||
public override void OnStartRunStage() | ||
{ | ||
foreach (var eventProcessor in eventProcessors) | ||
eventProcessor.OnStartRunStage(); | ||
} | ||
|
||
public override void OnEndRunStage() | ||
{ | ||
foreach (var eventProcessor in eventProcessors) | ||
eventProcessor.OnEndRunStage(); | ||
} | ||
|
||
public override void OnStartRunBenchmarksInType(Type type, IReadOnlyList<BenchmarkCase> benchmarks) | ||
{ | ||
foreach (var eventProcessor in eventProcessors) | ||
eventProcessor.OnStartRunBenchmarksInType(type, benchmarks); | ||
} | ||
|
||
public override void OnEndRunBenchmarksInType(Type type, Summary summary) | ||
{ | ||
foreach (var eventProcessor in eventProcessors) | ||
eventProcessor.OnEndRunBenchmarksInType(type, summary); | ||
} | ||
|
||
public override void OnEndRunBenchmark(BenchmarkCase benchmarkCase, BenchmarkReport report) | ||
{ | ||
foreach (var eventProcessor in eventProcessors) | ||
eventProcessor.OnEndRunBenchmark(benchmarkCase, report); | ||
} | ||
|
||
public override void OnStartRunBenchmark(BenchmarkCase benchmarkCase) | ||
{ | ||
foreach (var eventProcessor in eventProcessors) | ||
eventProcessor.OnStartRunBenchmark(benchmarkCase); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using BenchmarkDotNet.Reports; | ||
using BenchmarkDotNet.Running; | ||
using BenchmarkDotNet.Toolchains.Results; | ||
using BenchmarkDotNet.Validators; | ||
|
||
namespace BenchmarkDotNet.EventProcessors | ||
{ | ||
public abstract class EventProcessor | ||
{ | ||
public virtual void OnStartValidationStage() { } | ||
public virtual void OnValidationError(ValidationError validationError) { } | ||
public virtual void OnEndValidationStage() { } | ||
public virtual void OnStartBuildStage(IReadOnlyList<BuildPartition> partitions) { } | ||
public virtual void OnBuildComplete(BuildPartition partition, BuildResult buildResult) { } | ||
public virtual void OnEndBuildStage() { } | ||
public virtual void OnStartRunStage() { } | ||
public virtual void OnStartRunBenchmarksInType(Type type, IReadOnlyList<BenchmarkCase> benchmarks) { } | ||
public virtual void OnEndRunBenchmarksInType(Type type, Summary summary) { } | ||
public virtual void OnStartRunBenchmark(BenchmarkCase benchmarkCase) { } | ||
public virtual void OnEndRunBenchmark(BenchmarkCase benchmarkCase, BenchmarkReport report) { } | ||
public virtual void OnEndRunStage() { } | ||
} | ||
} |
Oops, something went wrong.