1
1
using System ;
2
+ using System . Collections . Generic ;
2
3
using System . IO ;
3
4
using BenchmarkDotNet . Attributes ;
4
5
using Exceptionless . Extensions ;
9
10
10
11
namespace Exceptionless . Tests . Plugins {
11
12
public class DeduplicationBenchmarks {
13
+ private readonly List < Event > _events = new List < Event > ( ) ;
14
+ public DeduplicationBenchmarks ( ) {
15
+ foreach ( var file in Directory . GetFiles ( @"..\..\ErrorData" , "*.json" ) ) {
16
+ _events . Add ( GetEvent ( file ) ) ;
17
+ }
18
+ }
12
19
protected virtual IJsonSerializer GetSerializer ( ) {
13
20
return new DefaultJsonSerializer ( ) ;
14
21
}
@@ -25,48 +32,15 @@ public void TestBenchmark1() {
25
32
var errorPlugin = new ErrorPlugin ( ) ;
26
33
var duplicateCheckerPlugin = new DuplicateCheckerPlugin ( ) ;
27
34
28
- var ev = GetEvent ( @"..\..\ErrorData\1.json" ) ;
29
- var pluginContextData = new ContextData ( ) ;
30
-
31
- for ( int index = 0 ; index < 2 ; index ++ ) {
32
- var context = new EventPluginContext ( client , ev , pluginContextData ) ;
33
-
34
- errorPlugin . Run ( context ) ;
35
- duplicateCheckerPlugin . Run ( context ) ;
36
- }
37
- }
38
-
39
- [ Benchmark ]
40
- public void TestBenchmark2 ( ) {
41
- var client = new ExceptionlessClient ( ) ;
42
- var errorPlugin = new ErrorPlugin ( ) ;
43
- var duplicateCheckerPlugin = new DuplicateCheckerPlugin ( ) ;
44
-
45
- var ev = GetEvent ( @"..\..\ErrorData\2.json" ) ;
46
- var pluginContextData = new ContextData ( ) ;
47
-
48
- for ( int index = 0 ; index < 2 ; index ++ ) {
49
- var context = new EventPluginContext ( client , ev , pluginContextData ) ;
50
-
51
- errorPlugin . Run ( context ) ;
52
- duplicateCheckerPlugin . Run ( context ) ;
53
- }
54
- }
55
-
56
- [ Benchmark ]
57
- public void TestBenchmark3 ( ) {
58
- var client = new ExceptionlessClient ( ) ;
59
- var errorPlugin = new ErrorPlugin ( ) ;
60
- var duplicateCheckerPlugin = new DuplicateCheckerPlugin ( ) ;
61
-
62
- var ev = GetEvent ( @"..\..\ErrorData\3.json" ) ;
63
- var pluginContextData = new ContextData ( ) ;
35
+ foreach ( var ev in _events ) {
36
+ var pluginContextData = new ContextData ( ) ;
64
37
65
- for ( int index = 0 ; index < 2 ; index ++ ) {
66
- var context = new EventPluginContext ( client , ev , pluginContextData ) ;
38
+ for ( int index = 0 ; index < 2 ; index ++ ) {
39
+ var context = new EventPluginContext ( client , ev , pluginContextData ) ;
67
40
68
- errorPlugin . Run ( context ) ;
69
- duplicateCheckerPlugin . Run ( context ) ;
41
+ errorPlugin . Run ( context ) ;
42
+ duplicateCheckerPlugin . Run ( context ) ;
43
+ }
70
44
}
71
45
}
72
46
}
0 commit comments