Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/rare-queens-doubt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@biomejs/biome": minor
---

Added the rule profiler behind the `--profile-rules` cli flag. You can now see a report of which lint rules took the longest to execute.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions crates/biome_analyze/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ rustc-hash = { workspace = true }
schemars = { workspace = true, optional = true }
serde = { workspace = true, features = ["derive"], optional = true }

[dev-dependencies]
insta = { workspace = true }

[features]
schema = ["biome_console/schema", "dep:schemars", "serde"]
serde = ["dep:biome_deserialize", "dep:biome_deserialize_macros", "dep:serde"]
Expand Down
40 changes: 22 additions & 18 deletions crates/biome_analyze/src/analyzer_plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ use std::{fmt::Debug, sync::Arc};
use biome_rowan::{AnySyntaxNode, Language, RawSyntaxKind, SyntaxKind, SyntaxNode, WalkEvent};

use crate::matcher::SignalRuleKey;
use crate::{DiagnosticSignal, RuleCategory, RuleDiagnostic, SignalEntry, Visitor, VisitorContext};
use crate::{
DiagnosticSignal, RuleCategory, RuleDiagnostic, SignalEntry, Visitor, VisitorContext, profiling,
};

/// Slice of analyzer plugins that can be cheaply cloned.
pub type AnalyzerPluginSlice<'a> = &'a [Arc<Box<dyn AnalyzerPlugin>>];
Expand Down Expand Up @@ -100,24 +102,26 @@ where
return;
}

let signals = self
let rule_timer = profiling::start_plugin_rule("plugin");
let diagnostics = self
.plugin
.evaluate(node.clone().into(), ctx.options.file_path.clone())
.into_iter()
.map(|diagnostic| {
let name = diagnostic
.subcategory
.clone()
.unwrap_or_else(|| "anonymous".into());

SignalEntry {
text_range: diagnostic.span().unwrap_or_default(),
signal: Box::new(DiagnosticSignal::new(move || diagnostic.clone())),
rule: SignalRuleKey::Plugin(name.into()),
category: RuleCategory::Lint,
instances: Default::default(),
}
});
.evaluate(node.clone().into(), ctx.options.file_path.clone());
rule_timer.stop();

let signals = diagnostics.into_iter().map(|diagnostic| {
let name = diagnostic
.subcategory
.clone()
.unwrap_or_else(|| "anonymous".into());

SignalEntry {
text_range: diagnostic.span().unwrap_or_default(),
signal: Box::new(DiagnosticSignal::new(move || diagnostic.clone())),
rule: SignalRuleKey::Plugin(name.into()),
category: RuleCategory::Lint,
instances: Default::default(),
}
});

ctx.signal_queue.extend(signals);
}
Expand Down
1 change: 1 addition & 0 deletions crates/biome_analyze/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ pub mod context;
mod diagnostics;
mod matcher;
pub mod options;
pub mod profiling;
mod query;
mod registry;
mod rule;
Expand Down
Loading
Loading