chore(xtask): bench analyzer on better files
ADD
xtask/bench/src/analyzer-libs-js.txt
+https://raw.githubusercontent.com/prettier/prettier/main/src/language-js/utils/index.js
+https://raw.githubusercontent.com/jquery/jquery/main/src/css.js
\ No newline at end of file

ADD
xtask/bench/src/analyzer-libs-ts.txt
+https://raw.githubusercontent.com/angular/angular/master/packages/compiler/src/expression_parser/parser.ts
+https://raw.githubusercontent.com/angular/angular/master/packages/router/src/router.ts
+https://raw.githubusercontent.com/rome/tools/archived-js/internal/js-parser/parser/statement.ts
+https://raw.githubusercontent.com/rome/tools/archived-js/internal/diagnostics/descriptions/lint.ts
+https://raw.githubusercontent.com/rome/tools/archived-js/internal/js-parser/parser/typescript.ts
\ No newline at end of file

MODIFY
xtask/bench/src/features/analyzer.rs
xtask/bench/src/features/analyzer.rs
use crate::BenchmarkSummary;
use criterion::black_box;
-use rome_analyze::{AnalysisFilter, ControlFlow, Never};
+use rome_analyze::{AnalysisFilter, ControlFlow, Never, RuleCategories};
use rome_js_analyze::analyze;
use rome_js_syntax::JsAnyRoot;
use std::fmt::{Display, Formatter};
@@ -23,7 +23,12 @@ pub fn benchmark_analyze_lib(id: &str, root: &JsAnyRoot) -> BenchmarkSummary {
}
pub fn run_analyzer(root: &JsAnyRoot) {
- analyze(0, root, AnalysisFilter::default(), |event| {
+ let filter = AnalysisFilter {
+ categories: RuleCategories::SYNTAX | RuleCategories::LINT,
+ ..AnalysisFilter::default()
+ };
+
+ analyze(0, root, filter, |event| {
black_box(event.diagnostic());
black_box(event.action());
ControlFlow::<Never>::Continue(())

MODIFY
xtask/bench/src/lib.rs
xtask/bench/src/lib.rs
@@ -19,6 +19,7 @@ use crate::features::parser::{run_parse, ParseMeasurement};
pub use utils::get_code;
/// What feature to benchmark
+#[derive(Eq, PartialEq)]
pub enum FeatureToBenchmark {
/// benchmark of the parser
Parser,
@@ -95,8 +96,13 @@ pub fn run(args: RunArgs) {
let regex = regex::Regex::new(args.filter.as_str()).unwrap();
let mut all_suites = HashMap::new();
+ if args.feature == FeatureToBenchmark::Analyzer {
+ all_suites.insert("js", include_str!("analyzer-libs-js.txt"));
+ all_suites.insert("ts", include_str!("analyzer-libs-ts.txt"));
+ } else {
all_suites.insert("js", include_str!("libs-js.txt"));
all_suites.insert("ts", include_str!("libs-ts.txt"));
+ }
let mut libs = vec![];
let suites_to_run = args.suites.split(',');

chore(xtask): bench analyzer on better files (#2847)