mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-02 19:32:17 +00:00
refactor cli/src/build.rs
This commit is contained in:
parent
a2c760aa56
commit
1995d8b3df
5 changed files with 235 additions and 156 deletions
|
@ -1148,6 +1148,51 @@ impl ModuleTiming {
|
|||
}
|
||||
}
|
||||
|
||||
fn report_timing(
|
||||
buf: &mut impl std::fmt::Write,
|
||||
label: &str,
|
||||
duration: Duration,
|
||||
) -> std::fmt::Result {
|
||||
writeln!(
|
||||
buf,
|
||||
" {:9.3} ms {}",
|
||||
duration.as_secs_f64() * 1000.0,
|
||||
label,
|
||||
)
|
||||
}
|
||||
|
||||
impl std::fmt::Display for ModuleTiming {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
let module_timing = self;
|
||||
|
||||
report_timing(f, "Read .roc file from disk", module_timing.read_roc_file)?;
|
||||
report_timing(f, "Parse header", module_timing.parse_header)?;
|
||||
report_timing(f, "Parse body", module_timing.parse_body)?;
|
||||
report_timing(f, "Canonicalize", module_timing.canonicalize)?;
|
||||
report_timing(f, "Constrain", module_timing.constrain)?;
|
||||
report_timing(f, "Solve", module_timing.solve)?;
|
||||
report_timing(
|
||||
f,
|
||||
"Find Specializations",
|
||||
module_timing.find_specializations,
|
||||
)?;
|
||||
let multiple_make_specializations_passes = module_timing.make_specializations.len() > 1;
|
||||
for (i, pass_time) in module_timing.make_specializations.iter().enumerate() {
|
||||
let suffix = if multiple_make_specializations_passes {
|
||||
format!(" (Pass {})", i)
|
||||
} else {
|
||||
String::new()
|
||||
};
|
||||
report_timing(f, &format!("Make Specializations{}", suffix), *pass_time)?;
|
||||
}
|
||||
report_timing(f, "Other", module_timing.other())?;
|
||||
f.write_str("\n")?;
|
||||
report_timing(f, "Total", module_timing.total())?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
/// A message sent _to_ a worker thread, describing the work to be done
|
||||
#[derive(Debug)]
|
||||
#[allow(dead_code)]
|
||||
|
|
|
@ -24,6 +24,22 @@ impl OperatingSystem {
|
|||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
pub const fn object_file_ext(&self) -> &str {
|
||||
match self {
|
||||
OperatingSystem::Windows => "obj",
|
||||
OperatingSystem::Unix => "o",
|
||||
OperatingSystem::Wasi => "o",
|
||||
}
|
||||
}
|
||||
|
||||
pub const fn executable_file_ext(&self) -> Option<&str> {
|
||||
match self {
|
||||
OperatingSystem::Windows => Some("exe"),
|
||||
OperatingSystem::Unix => None,
|
||||
OperatingSystem::Wasi => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<target_lexicon::OperatingSystem> for OperatingSystem {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue