@@ -25,7 +25,7 @@ public class Program
25
25
private const string ProcessedDirectoryName = "processed" ;
26
26
27
27
private const string BenchmarkRequest = "@aspnet-hello benchmark" ;
28
- private const string StartingBencmarkComment = "Starting pipelined plaintext benchmark with session ID '{0 }'. This could take up to 30 minutes..." ;
28
+ private const string StartingBencmarkComment = "Starting '{0}' pipelined plaintext benchmark with session ID '{1 }'. This could take up to 30 minutes..." ;
29
29
private const string CompletedBenchmarkCommentTemplate = "## Baseline\n \n ```\n {0}\n ```\n \n ## PR\n \n ```\n {1}\n ```" ;
30
30
31
31
private static readonly DateTime CommentCutoffDate = DateTime . Now . AddHours ( - 24 ) ;
@@ -130,20 +130,22 @@ public static int Main(string[] args)
130
130
131
131
Console . WriteLine ( $ "Scanning for benchmark requests in { Owner } /{ Repo } .") ;
132
132
133
- await foreach ( var pr in GetPRsToBenchmark ( client , botLoginName ) )
133
+ await foreach ( var prBenchmarkRequest in GetPRsToBenchmark ( client , botLoginName ) )
134
134
{
135
+ var pr = prBenchmarkRequest . PullRequest ;
136
+
135
137
try
136
138
{
137
139
var session = Guid . NewGuid ( ) . ToString ( "n" ) ;
138
140
var newJobFileName = $ "{ session } .{ Path . GetFileName ( BaseJobPath ) } ";
139
- var startingCommentText = string . Format ( StartingBencmarkComment , session ) ;
141
+ var startingCommentText = string . Format ( StartingBencmarkComment , prBenchmarkRequest . ScenarioName , session ) ;
140
142
141
- Console . WriteLine ( $ "Requesting benchmark for PR #{ pr . Number } .") ;
143
+ Console . WriteLine ( $ "Requesting { prBenchmarkRequest . ScenarioName } benchmark for PR #{ pr . Number } .") ;
142
144
Console . WriteLine ( $ "Benchmark starting comment: { startingCommentText } ") ;
143
145
144
146
await client . Issue . Comment . Create ( Owner , Repo , pr . Number , startingCommentText ) ;
145
147
146
- await RequestBenchmark ( pr , newJobFileName ) ;
148
+ await RequestBenchmark ( prBenchmarkRequest , newJobFileName ) ;
147
149
148
150
Console . WriteLine ( $ "Benchmark requested for PR #{ pr . Number } . Waiting up to { BenchmarkTimeout } for results.") ;
149
151
var results = await WaitForBenchmarkResults ( newJobFileName ) ;
@@ -179,7 +181,7 @@ string FormatOutput(string stdout, string stderr)
179
181
return app . Execute ( args ) ;
180
182
}
181
183
182
- private static async IAsyncEnumerable < PullRequest > GetPRsToBenchmark ( GitHubClient client , string botLoginName )
184
+ private static async IAsyncEnumerable < PRBenchmarkRequest > GetPRsToBenchmark ( GitHubClient client , string botLoginName )
183
185
{
184
186
var prRequest = new PullRequestRequest ( )
185
187
{
@@ -210,7 +212,18 @@ private static async IAsyncEnumerable<PullRequest> GetPRsToBenchmark(GitHubClien
210
212
211
213
if ( comment . Body . StartsWith ( BenchmarkRequest ) && await client . Organization . Member . CheckMember ( Owner , comment . User . Login ) )
212
214
{
213
- yield return pr ;
215
+ var scenarioName = comment . Body . Substring ( BenchmarkRequest . Length ) . Trim ( ) ;
216
+
217
+ if ( string . IsNullOrWhiteSpace ( scenarioName ) )
218
+ {
219
+ scenarioName = "Default" ;
220
+ }
221
+
222
+ yield return new PRBenchmarkRequest
223
+ {
224
+ ScenarioName = scenarioName ,
225
+ PullRequest = pr ,
226
+ } ;
214
227
}
215
228
else if ( comment . User . Login . Equals ( botLoginName , StringComparison . OrdinalIgnoreCase ) )
216
229
{
@@ -244,18 +257,33 @@ private static async Task<string[]> GetBuildCommands()
244
257
return buildInstructions . BuildCommands ;
245
258
}
246
259
247
- private static async Task RequestBenchmark ( PullRequest pr , string newJobFileName )
260
+ private static async Task RequestBenchmark ( PRBenchmarkRequest prBenchmarkRequest , string newJobFileName )
248
261
{
249
262
await using var baseJobStream = File . OpenRead ( BaseJobPath ) ;
250
263
251
264
var jsonDictionary = await JsonSerializer . DeserializeAsync < Dictionary < string , object > > ( baseJobStream ) ;
252
265
266
+ var extraDriverArgs = "" ;
267
+ if ( jsonDictionary . ContainsKey ( prBenchmarkRequest . ScenarioName ) )
268
+ {
269
+ var scenarioElement = ( JsonElement ) jsonDictionary [ prBenchmarkRequest . ScenarioName ] ;
270
+
271
+ if ( scenarioElement . TryGetProperty ( "ExtraDriverArgs" , out var extraDriverArgsElement ) )
272
+ {
273
+ extraDriverArgs = extraDriverArgsElement . GetString ( ) ;
274
+ }
275
+ }
276
+
277
+ var pr = prBenchmarkRequest . PullRequest ;
278
+
253
279
jsonDictionary [ "BuildInstructions" ] = new BuildInstructions
254
280
{
255
281
BuildCommands = BuildCommands ,
256
282
PullRequestNumber = pr . Number ,
257
283
BaselineSHA = pr . Base . Sha ,
258
284
PullRequestSHA = pr . Head . Sha ,
285
+ ScenarioName = prBenchmarkRequest . ScenarioName ,
286
+ ExtraDriverArgs = extraDriverArgs ,
259
287
} ;
260
288
261
289
using var newJobStream = new MemoryStream ( ) ;
@@ -410,6 +438,9 @@ private class BuildInstructions
410
438
public int PullRequestNumber { get ; set ; }
411
439
public string BaselineSHA { get ; set ; }
412
440
public string PullRequestSHA { get ; set ; }
441
+
442
+ public string ScenarioName { get ; set ; }
443
+ public string ExtraDriverArgs { get ; set ; }
413
444
}
414
445
415
446
private class BenchmarkResult
0 commit comments