-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #719 - Mark-Simulacrum:shrink-html-report, r=Mark-Simul…
…acrum Update tera/minifier & cut some memory allocations
- Loading branch information
Showing
8 changed files
with
279 additions
and
108 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
use crater::experiments::ExperimentDBRecord; | ||
use crater::report::ReportWriter; | ||
use crater::results::EncodingType; | ||
use crater::{config::Config, db::QueryUtils}; | ||
use failure::Fallible; | ||
use mime::{self, Mime}; | ||
use std::{borrow::Cow, fmt, path::Path}; | ||
|
||
fn main() { | ||
let mut env = env_logger::Builder::new(); | ||
env.filter_module("test_report", log::LevelFilter::Info); | ||
env.filter_module("crater", log::LevelFilter::Info); | ||
env.filter_module("rustwide", log::LevelFilter::Info); | ||
if let Ok(content) = std::env::var("RUST_LOG") { | ||
env.parse_filters(&content); | ||
} | ||
rustwide::logging::init_with(env.build()); | ||
let config: Config = toml::from_str(&std::fs::read_to_string("config.toml").unwrap()).unwrap(); | ||
let db = crater::db::Database::open_at(std::path::Path::new("crater.db")).unwrap(); | ||
let experiments = db | ||
.query("SELECT * FROM experiments;", [], |r| { | ||
ExperimentDBRecord::from_row(r) | ||
}) | ||
.unwrap(); | ||
let experiments: Vec<_> = experiments | ||
.into_iter() | ||
.map(|record| record.into_experiment()) | ||
.collect::<Fallible<_>>() | ||
.unwrap(); | ||
let ex = experiments.iter().find(|e| e.name == "pr-118920").unwrap(); | ||
let rdb = crater::results::DatabaseDB::new(&db); | ||
|
||
log::info!("Getting crates..."); | ||
|
||
let crates = ex.get_crates(&db).unwrap(); | ||
let writer = NullWriter; | ||
|
||
log::info!("Starting report generation..."); | ||
log::info!( | ||
"@ {:?}", | ||
nix::sys::resource::getrusage(nix::sys::resource::UsageWho::RUSAGE_SELF) | ||
.unwrap() | ||
.max_rss() | ||
); | ||
crater::report::gen(&rdb, ex, &crates, &writer, &config, false).unwrap(); | ||
log::info!( | ||
"@ {:?}", | ||
nix::sys::resource::getrusage(nix::sys::resource::UsageWho::RUSAGE_SELF) | ||
.unwrap() | ||
.max_rss() | ||
); | ||
} | ||
|
||
#[derive(Debug)] | ||
struct NullWriter; | ||
|
||
impl ReportWriter for NullWriter { | ||
fn write_bytes<P: AsRef<Path>>( | ||
&self, | ||
_path: P, | ||
_b: &[u8], | ||
_mime: &Mime, | ||
_encoding_type: EncodingType, | ||
) -> Fallible<()> { | ||
// no-op | ||
Ok(()) | ||
} | ||
fn write_string<P: AsRef<Path>>(&self, _path: P, _s: Cow<str>, _mime: &Mime) -> Fallible<()> { | ||
// no-op | ||
Ok(()) | ||
} | ||
} | ||
|
||
impl fmt::Display for NullWriter { | ||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { | ||
write!(f, "{:?}", self) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters