Skip to content

Commit 90331f9

Browse files
committed
move error generation outside of the benchmarked code
1 parent 8a2f718 commit 90331f9

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

Source/Tests/Plugins/DeduplicationBenchmarks.cs

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ public DeduplicationBenchmarks() {
2323
}
2424

2525
[Benchmark]
26-
[Fact]
2726
public void LargeEventsFromFiles() {
2827
foreach (var ev in _events) {
2928
var pluginContextData = new ContextData();
@@ -37,22 +36,29 @@ public void LargeEventsFromFiles() {
3736
}
3837
}
3938

39+
private EventBuilder _randomEventBuilder;
40+
private EventBuilder _fixedEventBuilder;
41+
42+
[Setup]
43+
public void Setup() {
44+
_randomEventBuilder = GetException(Guid.NewGuid().ToString()).ToExceptionless();
45+
_fixedEventBuilder = GetException().ToExceptionless();
46+
}
47+
4048
[Benchmark]
41-
[Fact]
4249
public void RandomExceptions() {
43-
var builder = GetException(Guid.NewGuid().ToString()).ToExceptionless();
44-
var context = new EventPluginContext(_client, builder.Target, builder.PluginContextData);
50+
var context = new EventPluginContext(_client, _randomEventBuilder.Target, _randomEventBuilder.PluginContextData);
4551

4652
_errorPlugin.Run(context);
4753
_duplicateCheckerPlugin.Run(context);
4854
}
4955

56+
57+
5058
[Benchmark]
51-
[Fact]
5259
public void IdenticalExceptions()
5360
{
54-
var builder = GetException().ToExceptionless();
55-
var context = new EventPluginContext(_client, builder.Target, builder.PluginContextData);
61+
var context = new EventPluginContext(_client, _fixedEventBuilder.Target, _fixedEventBuilder.PluginContextData);
5662

5763
_errorPlugin.Run(context);
5864
_duplicateCheckerPlugin.Run(context);

0 commit comments

Comments
 (0)