Remove lexing and parsing from the linter benchmark (#9264)

## Summary

This PR adds some helper structs to the linter paths to enable passing
in the pre-computed tokens and parsed source code during benchmarking,
to remove lexing and parsing from the overall linter benchmark
measurement. We already remove parsing for the formatter, and we have
separate benchmarks for the lexer and the parser, so this should make it
much easier to measure linter performance changes.
This commit is contained in:
Charlie Marsh 2023-12-23 16:43:11 -05:00 committed by GitHub
parent 6d0c9c4e95
commit 9d6444138b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 144 additions and 30 deletions

View file

@ -1293,7 +1293,7 @@ impl FusedIterator for Lexer<'_> {}
/// [lexer] implementation.
///
/// [lexer]: crate::lexer
#[derive(Debug, PartialEq)]
#[derive(Debug, Clone, PartialEq)]
pub struct LexicalError {
/// The type of error that occurred.
pub error: LexicalErrorType,
@ -1309,7 +1309,7 @@ impl LexicalError {
}
/// Represents the different types of errors that can occur during lexing.
#[derive(Debug, PartialEq)]
#[derive(Debug, Clone, PartialEq)]
pub enum LexicalErrorType {
// TODO: Can probably be removed, the places it is used seem to be able
// to use the `UnicodeError` variant instead.

View file

@ -409,7 +409,7 @@ pub(crate) fn concatenated_strings(
// TODO: consolidate these with ParseError
/// An error that occurred during parsing of an f-string.
#[derive(Debug, PartialEq)]
#[derive(Debug, Clone, PartialEq)]
struct FStringError {
/// The type of error that occurred.
pub(crate) error: FStringErrorType,
@ -427,7 +427,7 @@ impl From<FStringError> for LexicalError {
}
/// Represents the different types of errors that can occur during parsing of an f-string.
#[derive(Debug, PartialEq)]
#[derive(Debug, Clone, PartialEq)]
pub enum FStringErrorType {
/// Expected a right brace after an opened left brace.
UnclosedLbrace,