File tree Expand file tree Collapse file tree 2 files changed +34
-16
lines changed Expand file tree Collapse file tree 2 files changed +34
-16
lines changed Original file line number Diff line number Diff line change 1
1
using System ;
2
2
using System . Collections . Generic ;
3
- using System . IO ;
3
+ using System . Linq ;
4
4
using BenchmarkDotNet . Attributes ;
5
- using Exceptionless . Extensions ;
6
5
using Exceptionless . Models ;
7
6
using Exceptionless . Plugins ;
8
7
using Exceptionless . Plugins . Default ;
9
- using Exceptionless . Serializer ;
8
+ using Exceptionless . Tests . Utility ;
10
9
11
10
namespace Exceptionless . Tests . Plugins {
12
11
public class DeduplicationBenchmarks {
13
- private readonly List < Event > _events = new List < Event > ( ) ;
12
+ private readonly List < Event > _events ;
14
13
public DeduplicationBenchmarks ( ) {
15
- foreach ( var file in Directory . GetFiles ( @"..\..\ErrorData" , "*.json" ) ) {
16
- _events . Add ( GetEvent ( file ) ) ;
17
- }
18
- }
19
- protected virtual IJsonSerializer GetSerializer ( ) {
20
- return new DefaultJsonSerializer ( ) ;
21
- }
22
-
23
- Event GetEvent ( string fileName ) {
24
- var json = File . ReadAllText ( fileName ) ;
25
- var serializer = GetSerializer ( ) ;
26
- return serializer . Deserialize < Event > ( json ) ;
14
+ _events = ErrorDataReader . GetEvents ( ) . ToList ( ) ;
27
15
}
28
16
29
17
[ Benchmark ]
Original file line number Diff line number Diff line change
1
+ using System ;
2
+ using System . Collections . Generic ;
3
+ using System . IO ;
4
+ using System . Linq ;
5
+ using System . Text ;
6
+ using System . Threading . Tasks ;
7
+ using Exceptionless . Extensions ;
8
+ using Exceptionless . Models ;
9
+ using Exceptionless . Serializer ;
10
+
11
+ namespace Exceptionless . Tests . Utility
12
+ {
13
+ class ErrorDataReader
14
+ {
15
+ static IJsonSerializer GetSerializer ( )
16
+ {
17
+ return new DefaultJsonSerializer ( ) ;
18
+ }
19
+
20
+ static Event GetEvent ( string fileName )
21
+ {
22
+ var json = File . ReadAllText ( fileName ) ;
23
+ var serializer = GetSerializer ( ) ;
24
+ return serializer . Deserialize < Event > ( json ) ;
25
+ }
26
+ public static IEnumerable < Event > GetEvents ( ) {
27
+ return Directory . EnumerateFiles ( @"..\..\ErrorData" , "*.json" ) . Select ( GetEvent ) ;
28
+ }
29
+ }
30
+ }
You can’t perform that action at this time.
0 commit comments