3
3
using System . IO ;
4
4
using System . Text . RegularExpressions ;
5
5
using System . Threading . Tasks ;
6
- using System . Reflection ;
7
6
using Microsoft . Xunit . Performance . Api ;
8
7
using System . Runtime . InteropServices ;
8
+ using System . Globalization ;
9
9
10
10
namespace JitBench
11
11
{
12
- class Word2VecBenchmark : MLBenchmark
12
+ class Word2VecBenchmark : Benchmark
13
13
{
14
- public Word2VecBenchmark ( ) : base ( "Word2Vec" ) { }
14
+ private static readonly HashSet < int > DefaultExitCodes = new HashSet < int > ( new [ ] { 0 } ) ;
15
+
16
+ public Word2VecBenchmark ( ) : base ( "Word2Vec" )
17
+ {
18
+ ExePath = "Word2VecScenario.dll" ;
19
+ }
15
20
16
21
public override bool IsArchitectureSupported ( Architecture arch )
17
22
{
@@ -24,28 +29,10 @@ public override bool IsArchitectureSupported(Architecture arch)
24
29
//unless customers tell us its a problem'. I'm OK telling people not to use tiered jitting
25
30
//if their app already uses most of the address space on x86, and having an intermitently
26
31
//failing test in a perf suite won't give us useful info hence x64 only for this one.
27
- return arch == Architecture . X64 ;
28
- }
29
-
30
- protected override string ExecutableName => "Word2VecScenario.dll" ;
31
-
32
- protected override string GetWord2VecNetSrcDirectory ( string outputDir )
33
- {
34
- return Path . Combine ( GetWord2VecNetRepoRootDir ( outputDir ) , "Word2VecScenario" ) ;
35
- }
36
- }
37
-
38
- abstract class MLBenchmark : Benchmark
39
- {
40
- private static readonly HashSet < int > DefaultExitCodes = new HashSet < int > ( new [ ] { 0 } ) ;
41
32
42
- public MLBenchmark ( string name ) : base ( name )
43
- {
44
- ExePath = ExecutableName ;
33
+ return arch == Architecture . X64 ;
45
34
}
46
35
47
- protected abstract string ExecutableName { get ; }
48
-
49
36
public override async Task Setup ( DotNetInstallation dotNetInstall , string outputDir , bool useExistingSetup , ITestOutputHelper output )
50
37
{
51
38
if ( ! useExistingSetup )
@@ -67,11 +54,8 @@ async Task CloneWord2VecNetRepo(string outputDir, ITestOutputHelper output)
67
54
string word2VecNetRepoRootDir = GetWord2VecNetRepoRootDir ( outputDir ) ;
68
55
FileTasks . DeleteDirectory ( word2VecNetRepoRootDir , output ) ;
69
56
70
- string word2VecPatchFullPath = Path . Combine ( Path . GetDirectoryName ( Assembly . GetEntryAssembly ( ) . Location ) , Word2VecNetPatch ) ;
71
-
72
57
await ExecuteGitCommand ( $ "clone { Word2VecNetRepoUrl } { word2VecNetRepoRootDir } ", output ) ;
73
58
await ExecuteGitCommand ( $ "checkout { Word2VecNetCommitSha1Id } ", output , workingDirectory : word2VecNetRepoRootDir ) ;
74
- await ExecuteGitCommand ( $ "apply { word2VecPatchFullPath } ", output , workingDirectory : word2VecNetRepoRootDir ) ;
75
59
}
76
60
77
61
async Task ExecuteGitCommand ( string arguments , ITestOutputHelper output , string workingDirectory = null )
@@ -146,6 +130,7 @@ void AddConsoleMetrics(IterationResult result, string stdout, ITestOutputHelper
146
130
double ? trainingTime = null ;
147
131
double ? firstSearchTime = null ;
148
132
double ? steadyStateMedianTime = null ;
133
+ var currentDecimalSeparator = CultureInfo . CurrentCulture . NumberFormat . NumberDecimalSeparator ;
149
134
150
135
using ( var reader = new StringReader ( stdout ) )
151
136
{
@@ -166,7 +151,7 @@ void AddConsoleMetrics(IterationResult result, string stdout, ITestOutputHelper
166
151
continue ;
167
152
}
168
153
169
- match = Regex . Match ( line , @"^Steadystate median search time: \s*(\d+\. \d+)ms$" ) ;
154
+ match = Regex . Match ( line , $ @ "^Steadystate median search time: \s*(\d+\{ currentDecimalSeparator } \d+)ms$") ;
170
155
if ( match . Success && match . Groups . Count == 2 )
171
156
{
172
157
//many lines will match, but the final values of these variables will be from the last batch which is presumably the
@@ -226,7 +211,10 @@ protected static string GetWord2VecNetRepoRootDir(string outputDir)
226
211
return Path . Combine ( outputDir , "W" ) ;
227
212
}
228
213
229
- protected abstract string GetWord2VecNetSrcDirectory ( string outputDir ) ;
214
+ protected string GetWord2VecNetSrcDirectory ( string outputDir )
215
+ {
216
+ return Path . Combine ( GetWord2VecNetRepoRootDir ( outputDir ) , "Word2VecScenario" ) ;
217
+ }
230
218
231
219
string GetWord2VecNetPublishDirectory ( DotNetInstallation dotNetInstall , string outputDir , string tfm )
232
220
{
@@ -257,15 +245,11 @@ string GetCoreClrRoot()
257
245
return workspace ;
258
246
}
259
247
260
- private const string Word2VecNetRepoUrl = "https://github.com/eabdullin/Word2Vec.Net" ;
261
- private const string Word2VecNetCommitSha1Id = "6012a2b5b886926918d51b1b56387d785115f448" ;
262
- private const string Word2VecNetPatch = "word2vecnet.patch" ;
263
- private const string EnvironmentFileName = "Word2VecNetEnvironment.txt" ;
264
- private const string StoreDirName = ".store" ;
248
+ private const string Word2VecNetRepoUrl = "https://github.com/dotnet-perf-bot/Word2Vec.Net.git" ;
249
+ private const string Word2VecNetCommitSha1Id = "bbf60216bd735ba2ccc3a54570ce735789968f2d" ;
265
250
private readonly Metric TrainingMetric = new Metric ( "Training" , "ms" ) ;
266
251
private readonly Metric FirstSearchMetric = new Metric ( "First Search" , "ms" ) ;
267
252
private readonly Metric MedianSearchMetric = new Metric ( "Median Search" , "ms" ) ;
268
- private readonly Metric MeanSearchMetric = new Metric ( "Mean Search" , "ms" ) ;
269
253
}
270
254
}
271
255
0 commit comments