Skip to content

Commit

Permalink
Add measures for AST conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
yannham committed Nov 25, 2024
1 parent 1274e47 commit 4641104
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions core/src/parser/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use crate::bytecode::ast::{
use crate::error::{ParseError, ParseErrors};
use crate::files::FileId;
use crate::identifier::LocIdent;
use crate::metrics;
use crate::position::RawSpan;
use lalrpop_util::lalrpop_mod;

Expand Down Expand Up @@ -212,8 +213,12 @@ macro_rules! generate_compat_impl {
lexer: lexer::Lexer,
) -> Result<($output, ParseErrors), ParseError> {
let alloc = AstAlloc::new();
self.parse_tolerant(&alloc, file_id, lexer)
.map(|(t, e)| (t.to_mainline(), e))
self.parse_tolerant(&alloc, file_id, lexer).map(|(t, e)| {
(
metrics::measure_runtime!("runtime:ast_conversion", t.to_mainline()),
e,
)
})
}

fn parse_strict_compat(
Expand All @@ -223,7 +228,7 @@ macro_rules! generate_compat_impl {
) -> Result<$output, ParseErrors> {
let alloc = AstAlloc::new();
self.parse_strict(&alloc, file_id, lexer)
.map(|t| t.to_mainline())
.map(|t| metrics::measure_runtime!("runtime:ast_conversion", t.to_mainline()))
}
}
};
Expand All @@ -236,7 +241,6 @@ generate_compat_impl!(
generate_compat_impl!(grammar::TermParser, crate::term::RichTerm);
generate_compat_impl!(grammar::FixedTypeParser, crate::typ::Type);

// We could have implemented ToMainline
impl<'ast> ErrorTolerantParserCompat<(Vec<LocIdent>, crate::term::RichTerm, RawSpan)>
for grammar::CliFieldAssignmentParser
{
Expand Down

0 comments on commit 4641104

Please sign in to comment.