Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions database/src/bin/ingest-json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -921,12 +921,7 @@ async fn ingest<T: Ingesting>(conn: &T, caches: &mut IdCache, path: &Path) {
} else {
Profile::Debug
};
let profile_str = match profile {
Profile::Check => "check",
Profile::Debug => "debug",
Profile::Doc => "doc",
Profile::Opt => "opt",
};
let profile_str = profile.as_str();
let state = match &run.state {
BenchmarkState::Clean => Scenario::Empty,
BenchmarkState::IncrementalStart => Scenario::IncrementalEmpty,
Expand Down
22 changes: 12 additions & 10 deletions database/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,17 @@ pub enum Profile {
Opt,
}

impl Profile {
pub fn as_str(self) -> &'static str {
match self {
Profile::Check => "check",
Profile::Opt => "opt",
Profile::Debug => "debug",
Profile::Doc => "doc",
}
}
}

impl std::str::FromStr for Profile {
type Err = String;
fn from_str(s: &str) -> Result<Self, Self::Err> {
Expand All @@ -241,16 +252,7 @@ impl std::str::FromStr for Profile {

impl fmt::Display for Profile {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(
f,
"{}",
match self {
Profile::Check => "check",
Profile::Opt => "opt",
Profile::Debug => "debug",
Profile::Doc => "doc",
}
)
write!(f, "{}", self.as_str())
}
}

Expand Down
8 changes: 1 addition & 7 deletions database/src/pool/postgres.rs
Original file line number Diff line number Diff line change
Expand Up @@ -546,13 +546,7 @@ where
row.get::<_, i32>(0) as u32,
(
Benchmark::from(row.get::<_, String>(1).as_str()),
match row.get::<_, String>(2).as_str() {
"check" => Profile::Check,
"opt" => Profile::Opt,
"debug" => Profile::Debug,
"doc" => Profile::Doc,
o => unreachable!("{}: not a profile", o),
},
Profile::from_str(row.get::<_, String>(2).as_str()).unwrap(),
row.get::<_, String>(3).as_str().parse().unwrap(),
row.get::<_, String>(4).as_str().into(),
),
Expand Down
8 changes: 1 addition & 7 deletions database/src/pool/sqlite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -468,13 +468,7 @@ impl Connection for SqliteConnection {
row.get::<_, i32>(0)? as u32,
(
Benchmark::from(row.get::<_, String>(1)?.as_str()),
match row.get::<_, String>(2)?.as_str() {
"check" => Profile::Check,
"opt" => Profile::Opt,
"debug" => Profile::Debug,
"doc" => Profile::Doc,
o => unreachable!("{}: not a profile", o),
},
Profile::from_str(row.get::<_, String>(2)?.as_str()).unwrap(),
row.get::<_, String>(3)?.as_str().parse().unwrap(),
row.get::<_, String>(4)?.as_str().into(),
),
Expand Down