|
1 | 1 | use crate::pool::{Connection, ConnectionManager, ManagedConnection, Transaction}; |
| 2 | +use crate::selector::CompileTestCase; |
2 | 3 | use crate::{ |
3 | 4 | ArtifactCollection, ArtifactId, ArtifactIdNumber, Benchmark, CodegenBackend, CollectionId, |
4 | 5 | Commit, CommitType, CompileBenchmark, Date, Index, Profile, QueuedCommit, Scenario, Target, |
5 | 6 | }; |
6 | 7 | use anyhow::Context as _; |
7 | 8 | use chrono::{DateTime, TimeZone, Utc}; |
8 | | -use hashbrown::HashMap; |
| 9 | +use hashbrown::{HashMap, HashSet}; |
9 | 10 | use native_tls::{Certificate, TlsConnector}; |
10 | 11 | use postgres_native_tls::MakeTlsConnector; |
11 | 12 | use std::str::FromStr; |
@@ -366,6 +367,7 @@ pub struct CachedStatements { |
366 | 367 | get_runtime_pstat: Statement, |
367 | 368 | record_artifact_size: Statement, |
368 | 369 | get_artifact_size: Statement, |
| 370 | + get_compile_test_cases_with_measurements: Statement, |
369 | 371 | } |
370 | 372 |
|
371 | 373 | pub struct PostgresTransaction<'a> { |
@@ -547,7 +549,16 @@ impl PostgresConnection { |
547 | 549 | get_artifact_size: conn.prepare(" |
548 | 550 | select component, size from artifact_size |
549 | 551 | where aid = $1 |
550 | | - ").await.unwrap() |
| 552 | + ").await.unwrap(), |
| 553 | + get_compile_test_cases_with_measurements: conn.prepare(" |
| 554 | + SELECT DISTINCT crate, profile, scenario, backend, target |
| 555 | + FROM pstat_series |
| 556 | + WHERE id IN ( |
| 557 | + SELECT DISTINCT series |
| 558 | + FROM pstat |
| 559 | + WHERE aid = $1 |
| 560 | + ) |
| 561 | + ").await.unwrap(), |
551 | 562 | }), |
552 | 563 | conn, |
553 | 564 | } |
@@ -1365,6 +1376,30 @@ where |
1365 | 1376 | .await |
1366 | 1377 | .unwrap(); |
1367 | 1378 | } |
| 1379 | + |
| 1380 | + async fn get_compile_test_cases_with_measurements( |
| 1381 | + &self, |
| 1382 | + artifact_row_id: &ArtifactIdNumber, |
| 1383 | + ) -> anyhow::Result<HashSet<CompileTestCase>> { |
| 1384 | + let rows = self |
| 1385 | + .conn() |
| 1386 | + .query( |
| 1387 | + &self.statements().get_compile_test_cases_with_measurements, |
| 1388 | + &[&(artifact_row_id.0 as i32)], |
| 1389 | + ) |
| 1390 | + .await |
| 1391 | + .context("cannot query compile-time test cases with measurements")?; |
| 1392 | + Ok(rows |
| 1393 | + .into_iter() |
| 1394 | + .map(|row| CompileTestCase { |
| 1395 | + benchmark: Benchmark::from(row.get::<_, &str>(0)), |
| 1396 | + profile: Profile::from_str(row.get::<_, &str>(1)).unwrap(), |
| 1397 | + scenario: row.get::<_, &str>(2).parse().unwrap(), |
| 1398 | + backend: CodegenBackend::from_str(row.get::<_, &str>(3)).unwrap(), |
| 1399 | + target: Target::from_str(row.get::<_, &str>(4)).unwrap(), |
| 1400 | + }) |
| 1401 | + .collect()) |
| 1402 | + } |
1368 | 1403 | } |
1369 | 1404 |
|
1370 | 1405 | fn parse_artifact_id(ty: &str, sha: &str, date: Option<DateTime<Utc>>) -> ArtifactId { |
@@ -1397,4 +1432,7 @@ mod tests { |
1397 | 1432 | let certs = make_certificates().await; |
1398 | 1433 | assert!(!certs.is_empty()); |
1399 | 1434 | } |
| 1435 | + |
| 1436 | + #[tokio::test] |
| 1437 | + async fn foo() {} |
1400 | 1438 | } |
0 commit comments