@@ -8,7 +8,6 @@ use crate::load::InputData;
8
8
use crate :: selector:: { self , Tag } ;
9
9
10
10
use collector:: Bound ;
11
- use database:: Date ;
12
11
use serde:: Serialize ;
13
12
14
13
use std:: collections:: HashMap ;
@@ -60,8 +59,8 @@ pub async fn handle_triage(
60
59
} ;
61
60
log:: info!(
62
61
"Comparing {} to {}" ,
63
- comparison. b. commit ,
64
- comparison. a. commit
62
+ comparison. b. artifact ,
63
+ comparison. a. artifact
65
64
) ;
66
65
67
66
// handle results of comparison
@@ -84,9 +83,9 @@ pub async fn handle_triage(
84
83
}
85
84
86
85
pub async fn handle_compare (
87
- body : api:: days :: Request ,
86
+ body : api:: comparison :: Request ,
88
87
data : & InputData ,
89
- ) -> Result < api:: days :: Response , BoxedError > {
88
+ ) -> Result < api:: comparison :: Response , BoxedError > {
90
89
let master_commits = collector:: master_commits ( ) . await ?;
91
90
let end = body. end ;
92
91
let comparison =
@@ -99,10 +98,36 @@ pub async fn handle_compare(
99
98
let next = comparison. next ( & master_commits) ;
100
99
let is_contiguous = comparison. is_contiguous ( & * conn, & master_commits) . await ;
101
100
102
- Ok ( api:: days :: Response {
101
+ Ok ( api:: comparison :: Response {
103
102
prev,
104
- a : comparison. a ,
105
- b : comparison. b ,
103
+ a : api:: comparison:: ArtifactData {
104
+ commit : match comparison. a . artifact . clone ( ) {
105
+ ArtifactId :: Commit ( c) => c. sha ,
106
+ ArtifactId :: Artifact ( t) => t,
107
+ } ,
108
+ date : if let ArtifactId :: Commit ( c) = & comparison. a . artifact {
109
+ Some ( c. date )
110
+ } else {
111
+ None
112
+ } ,
113
+ pr : comparison. a . pr ,
114
+ data : comparison. a . data ,
115
+ bootstrap : comparison. a . bootstrap ,
116
+ } ,
117
+ b : api:: comparison:: ArtifactData {
118
+ commit : match comparison. b . artifact . clone ( ) {
119
+ ArtifactId :: Commit ( c) => c. sha ,
120
+ ArtifactId :: Artifact ( t) => t,
121
+ } ,
122
+ date : if let ArtifactId :: Commit ( c) = & comparison. b . artifact {
123
+ Some ( c. date )
124
+ } else {
125
+ None
126
+ } ,
127
+ pr : comparison. b . pr ,
128
+ data : comparison. b . data ,
129
+ bootstrap : comparison. b . bootstrap ,
130
+ } ,
106
131
next,
107
132
is_contiguous,
108
133
} )
@@ -197,8 +222,8 @@ impl ComparisonSummary<'_> {
197
222
} else {
198
223
String :: from ( "<Unknown Change>\n " )
199
224
} ;
200
- let start = & comparison. a . commit ;
201
- let end = & comparison. b . commit ;
225
+ let start = & comparison. a . artifact ;
226
+ let end = & comparison. b . artifact ;
202
227
let link = & compare_link ( start, end) ;
203
228
204
229
for change in self . ordered_changes ( ) {
@@ -246,27 +271,23 @@ pub async fn compare_given_commits(
246
271
. set :: < String > ( Tag :: Profile , selector:: Selector :: All )
247
272
. set ( Tag :: ProcessStatistic , selector:: Selector :: One ( stat. clone ( ) ) ) ;
248
273
249
- // `responses` contains a series iterators. The first element in the iterator is the data
274
+ // `responses` contains series iterators. The first element in the iterator is the data
250
275
// for `a` and the second is the data for `b`
251
276
let mut responses = data. query :: < Option < f64 > > ( query, cids) . await ?;
252
277
253
278
let conn = data. conn ( ) . await ;
254
279
255
280
Ok ( Some ( Comparison {
256
- a : DateData :: consume_one ( & * conn, a. clone ( ) , & mut responses, master_commits) . await ,
257
- a_id : a,
258
- b : DateData :: consume_one ( & * conn, b. clone ( ) , & mut responses, master_commits) . await ,
259
- b_id : b,
281
+ a : ArtifactData :: consume_one ( & * conn, a. clone ( ) , & mut responses, master_commits) . await ,
282
+ b : ArtifactData :: consume_one ( & * conn, b. clone ( ) , & mut responses, master_commits) . await ,
260
283
} ) )
261
284
}
262
285
263
286
/// Data associated with a specific artifact
264
287
#[ derive( Debug , Clone , Serialize ) ]
265
- pub struct DateData {
288
+ pub struct ArtifactData {
266
289
/// The artifact in question
267
- pub commit : String ,
268
- /// The date of the artifact if known
269
- pub date : Option < Date > ,
290
+ pub artifact : ArtifactId ,
270
291
/// The pr of the artifact if known
271
292
pub pr : Option < u32 > ,
272
293
/// Benchmark data in the form "$crate-$profile" -> Vec<("$cache", nanoseconds)>
@@ -279,14 +300,14 @@ pub struct DateData {
279
300
pub bootstrap : HashMap < String , u64 > ,
280
301
}
281
302
282
- impl DateData {
303
+ impl ArtifactData {
283
304
/// For the given `ArtifactId`, consume the first datapoint in each of the given `SeriesResponse`
284
305
///
285
- /// It is assumed that the provided ArtifactId is the same as artifact id returned as the next data
286
- /// point from all of the series `SeriesResponse`s . If this is not true, this function will panic.
306
+ /// It is assumed that the provided ` ArtifactId` matches the artifact id of the next data
307
+ /// point for all of `SeriesResponse<T>` . If this is not true, this function will panic.
287
308
async fn consume_one < ' a , T > (
288
309
conn : & dyn database:: Connection ,
289
- commit : ArtifactId ,
310
+ artifact : ArtifactId ,
290
311
series : & mut [ selector:: SeriesResponse < T > ] ,
291
312
master_commits : & [ collector:: MasterCommit ] ,
292
313
) -> Self
@@ -297,7 +318,7 @@ impl DateData {
297
318
298
319
for response in series {
299
320
let ( id, point) = response. series . next ( ) . expect ( "must have element" ) ;
300
- assert_eq ! ( commit , id) ;
321
+ assert_eq ! ( artifact , id) ;
301
322
302
323
let point = if let Some ( pt) = point {
303
324
pt
@@ -313,7 +334,9 @@ impl DateData {
313
334
. push ( ( response. path . get :: < Cache > ( ) . unwrap ( ) . to_string ( ) , point) ) ;
314
335
}
315
336
316
- let bootstrap = conn. get_bootstrap ( & [ conn. artifact_id ( & commit) . await ] ) . await ;
337
+ let bootstrap = conn
338
+ . get_bootstrap ( & [ conn. artifact_id ( & artifact) . await ] )
339
+ . await ;
317
340
let bootstrap = bootstrap
318
341
. into_iter ( )
319
342
. filter_map ( |( k, mut v) | {
@@ -332,25 +355,19 @@ impl DateData {
332
355
} )
333
356
. collect :: < HashMap < _ , _ > > ( ) ;
334
357
335
- Self {
336
- date : if let ArtifactId :: Commit ( c) = & commit {
337
- Some ( c. date )
338
- } else {
339
- None
340
- } ,
341
- pr : if let ArtifactId :: Commit ( c) = & commit {
342
- if let Some ( m) = master_commits. iter ( ) . find ( |m| m. sha == c. sha ) {
343
- m. pr
344
- } else {
345
- conn. pr_of ( & c. sha ) . await
346
- }
358
+ let pr = if let ArtifactId :: Commit ( c) = & artifact {
359
+ if let Some ( m) = master_commits. iter ( ) . find ( |m| m. sha == c. sha ) {
360
+ m. pr
347
361
} else {
348
- None
349
- } ,
350
- commit : match commit {
351
- ArtifactId :: Commit ( c) => c. sha ,
352
- ArtifactId :: Artifact ( i) => i,
353
- } ,
362
+ conn. pr_of ( & c. sha ) . await
363
+ }
364
+ } else {
365
+ None
366
+ } ;
367
+
368
+ Self {
369
+ pr,
370
+ artifact,
354
371
data,
355
372
bootstrap,
356
373
}
@@ -359,16 +376,14 @@ impl DateData {
359
376
360
377
// A comparison of two artifacts
361
378
pub struct Comparison {
362
- pub a_id : ArtifactId ,
363
- pub a : DateData ,
364
- pub b_id : ArtifactId ,
365
- pub b : DateData ,
379
+ pub a : ArtifactData ,
380
+ pub b : ArtifactData ,
366
381
}
367
382
368
383
impl Comparison {
369
384
/// Gets the previous commit before `a`
370
385
pub fn prev ( & self , master_commits : & [ collector:: MasterCommit ] ) -> Option < String > {
371
- match & self . a_id {
386
+ match & self . a . artifact {
372
387
ArtifactId :: Commit ( a) => master_commits
373
388
. iter ( )
374
389
. find ( |c| c. sha == a. sha )
@@ -383,7 +398,7 @@ impl Comparison {
383
398
conn : & dyn database:: Connection ,
384
399
master_commits : & [ collector:: MasterCommit ] ,
385
400
) -> bool {
386
- match ( & self . a_id , & self . b_id ) {
401
+ match ( & self . a . artifact , & self . b . artifact ) {
387
402
( ArtifactId :: Commit ( a) , ArtifactId :: Commit ( b) ) => {
388
403
if let Some ( b) = master_commits. iter ( ) . find ( |c| c. sha == b. sha ) {
389
404
b. parent_sha == a. sha
@@ -397,7 +412,7 @@ impl Comparison {
397
412
398
413
/// Gets the sha of the next commit after `b`
399
414
pub fn next ( & self , master_commits : & [ collector:: MasterCommit ] ) -> Option < String > {
400
- match & self . b_id {
415
+ match & self . b . artifact {
401
416
ArtifactId :: Commit ( b) => master_commits
402
417
. iter ( )
403
418
. find ( |c| c. parent_sha == b. sha )
@@ -585,7 +600,15 @@ TODO: Nags
585
600
)
586
601
}
587
602
588
- fn compare_link ( start : & str , end : & str ) -> String {
603
+ fn compare_link ( start : & ArtifactId , end : & ArtifactId ) -> String {
604
+ let start = match & start {
605
+ ArtifactId :: Artifact ( a) => a,
606
+ ArtifactId :: Commit ( c) => & c. sha ,
607
+ } ;
608
+ let end = match & end {
609
+ ArtifactId :: Artifact ( a) => a,
610
+ ArtifactId :: Commit ( c) => & c. sha ,
611
+ } ;
589
612
format ! (
590
613
"https://perf.rust-lang.org/compare.html?start={}&end={}&stat=instructions:u" ,
591
614
start, end
0 commit comments