Skip to content

Commit 706a634

Browse files
committed
Add benchmark to test different scenarios with generated exceptions
1 parent 0883777 commit 706a634

File tree

1 file changed

+36
-1
lines changed

1 file changed

+36
-1
lines changed

Source/Tests/Plugins/DeduplicationBenchmarks.cs

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using Exceptionless.Plugins;
77
using Exceptionless.Plugins.Default;
88
using Exceptionless.Tests.Utility;
9+
using Xunit;
910

1011
namespace Exceptionless.Tests.Plugins {
1112
public class DeduplicationBenchmarks {
@@ -22,7 +23,8 @@ public DeduplicationBenchmarks() {
2223
}
2324

2425
[Benchmark]
25-
public void TestBenchmark1() {
26+
[Fact]
27+
public void LargeEventsFromFiles() {
2628
foreach (var ev in _events) {
2729
var pluginContextData = new ContextData();
2830

@@ -34,5 +36,38 @@ public void TestBenchmark1() {
3436
}
3537
}
3638
}
39+
40+
[Benchmark]
41+
[Fact]
42+
public void RandomExceptions() {
43+
var builder = GetException(Guid.NewGuid().ToString()).ToExceptionless();
44+
var context = new EventPluginContext(_client, builder.Target, builder.PluginContextData);
45+
46+
_errorPlugin.Run(context);
47+
_duplicateCheckerPlugin.Run(context);
48+
}
49+
50+
[Benchmark]
51+
[Fact]
52+
public void IdenticalExceptions()
53+
{
54+
var builder = GetException().ToExceptionless();
55+
var context = new EventPluginContext(_client, builder.Target, builder.PluginContextData);
56+
57+
_errorPlugin.Run(context);
58+
_duplicateCheckerPlugin.Run(context);
59+
}
60+
61+
private Exception GetException(string message = "Test")
62+
{
63+
try
64+
{
65+
throw new Exception(message);
66+
}
67+
catch (Exception ex)
68+
{
69+
return ex;
70+
}
71+
}
3772
}
3873
}

0 commit comments

Comments
 (0)