-
-
Notifications
You must be signed in to change notification settings - Fork 983
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add event processor functionality #2420
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
ab86077
Add Event Handler support
caaavik-msft 313ebf1
Merge from master
caaavik-msft aa693f6
Update with latest from main
caaavik-msft 24872ec
Merge branch 'master' into caaavik/EventHandler
caaavik-msft 3f0936d
Add base event handler with virtual methods
caaavik-msft dca4fc7
Add integration tests and fix some bugs
caaavik-msft 9a2c9d4
Remove accidental newline
caaavik-msft c30931f
Address PR comments
caaavik-msft 916d9a5
Address more PR comments
caaavik-msft d78d33d
Make build completion events run sequentially
caaavik-msft e9d3deb
Address further PR comments
caaavik-msft 2c2fc9b
Apply suggestions from code review
adamsitnik File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@adamsitnik, @caaavik-msft
While this may be true, this makes it the only one of the
Add...
methods that doesn't accept a params array. Personally, I would prefer the API consistency.