add some Constraints statistics reporting

This commit is contained in:
Folkert 2022-03-19 20:50:22 +01:00
parent 9ac194a3b3
commit f5ebc5bec9
No known key found for this signature in database
GPG Key ID: 1F17F6FFD112B97C

View File

@ -1,7 +1,7 @@
use crate::expected::{Expected, PExpected};
use roc_collections::soa::{EitherIndex, Index, Slice};
use roc_module::ident::TagName;
use roc_module::symbol::Symbol;
use roc_module::symbol::{ModuleId, Symbol};
use roc_region::all::{Loc, Region};
use roc_types::subs::Variable;
use roc_types::types::{Category, PatternCategory, Type};
@ -140,6 +140,26 @@ impl Constraints {
}
}
pub fn statistics(&self, module_id: ModuleId) -> Result<String, std::fmt::Error> {
use std::fmt::Write;
let mut buf = String::new();
writeln!(buf, "Constraints statistics for module {:?}:", module_id)?;
writeln!(buf, " constraints length: {}:", self.constraints.len())?;
writeln!(buf, " types length: {}:", self.types.len())?;
writeln!(
buf,
" let_constraints length: {}:",
self.let_constraints.len()
)?;
writeln!(buf, " expectations length: {}:", self.expectations.len())?;
writeln!(buf, " categories length: {}:", self.categories.len())?;
Ok(buf)
}
#[inline(always)]
const fn push_type_variable(var: Variable) -> EitherIndex<Type, Variable> {
// that's right, we use the variable's integer value as the index