3
3
using System . IO ;
4
4
using System . Linq ;
5
5
using System . Runtime ;
6
- using System . Diagnostics . CodeAnalysis ;
7
6
8
7
namespace portent . Benchmark
9
8
{
10
9
public class DawgBenchmark : IDisposable
11
10
{
12
11
// Backtrack from /bin/$(Configuration)/netcore3.0/
13
- private const string SaveLocation = "../../../ lev7.aug ";
14
- private const string Query1K = "../../../ noisy_query_en_1000.txt";
12
+ private const string SaveLocation = @"C:\Users\JPelleri\source\repos\portent\portent.Benchmark\ lev7.augv5 ";
13
+ private const string Query1K = @"C:\Users\JPelleri\source\repos\portent\portent.Benchmark\ noisy_query_en_1000.txt";
15
14
16
- private readonly Dawg _dawg ;
15
+ internal readonly Dawg _dawg ;
17
16
private readonly string [ ] _words ;
18
17
19
18
public DawgBenchmark ( bool fromBenchmarkRunner )
20
19
{
21
- //Add a another level for the BenchmarkDotNet GUID folder
22
- var prefix = fromBenchmarkRunner ? "../" : string . Empty ;
23
-
20
+ var prefix = string . Empty ;
24
21
using var dawgStream = File . OpenRead ( prefix + SaveLocation ) ;
25
22
_dawg = new Dawg ( dawgStream ) ;
26
23
using var queryStream = File . OpenRead ( prefix + Query1K ) ;
@@ -29,10 +26,6 @@ public DawgBenchmark(bool fromBenchmarkRunner)
29
26
30
27
public DawgBenchmark ( ) : this ( true )
31
28
{
32
- if ( ! VerifyDawgCorrectness ( ) )
33
- {
34
- throw new InvalidOperationException ( "Dawg was not well formed." ) ;
35
- }
36
29
}
37
30
38
31
private static string [ ] BuildQuery1K ( Stream stream )
@@ -50,7 +43,7 @@ private static string[] BuildQuery1K(Stream stream)
50
43
while ( ( line = reader . ReadLine ( ) ) != null )
51
44
{
52
45
var lineParts = line . Split ( default ( char [ ] ) , StringSplitOptions . None ) ;
53
- if ( lineParts ? . Length == 3 )
46
+ if ( lineParts . Length == 3 )
54
47
{
55
48
testList [ i ++ ] = lineParts [ 0 ] ;
56
49
}
@@ -95,14 +88,14 @@ public static Dawg CreateDictionary(string corpusPath, string savePath)
95
88
96
89
var compressedGraph = builder . AsCompressedSparseRows ( ) ;
97
90
compressedGraph . Save ( savePath ) ;
98
- return new Dawg ( compressedGraph ) ;
91
+ using var dawgStream = File . OpenRead ( savePath ) ;
92
+ return new Dawg ( dawgStream ) ;
99
93
}
100
94
101
- [ Params ( 0 , 1 , 2 , 3 ) ]
95
+ [ Params ( 3u ) ]
102
96
public uint MaxErrors { get ; set ; }
103
97
104
98
[ GlobalSetup ]
105
- [ SuppressMessage ( "Performance" , "CA1822:Mark members as static" , Justification = "Used via reflection by DotNetBenchmark" ) ]
106
99
public void SetupForRun ( )
107
100
{
108
101
GCSettings . LatencyMode = GCLatencyMode . Batch ;
@@ -144,7 +137,7 @@ public void Benchmark()
144
137
}
145
138
}
146
139
147
- #region IDisposable Support
140
+ #region IDisposable Support
148
141
private bool _disposedValue ;
149
142
150
143
protected virtual void Dispose ( bool disposing )
@@ -165,6 +158,6 @@ public void Dispose()
165
158
Dispose ( true ) ;
166
159
GC . SuppressFinalize ( this ) ;
167
160
}
168
- #endregion
161
+ #endregion
169
162
}
170
163
}
0 commit comments