diff --git a/Cargo.lock b/Cargo.lock index 5b1159a0dfd8..ecf6bf1ccc66 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3549,6 +3549,8 @@ dependencies = [ "ansi_rgb", "biome_analyze", "biome_console", + "biome_css_parser", + "biome_css_syntax", "biome_diagnostics", "biome_formatter", "biome_js_analyze", diff --git a/xtask/bench/Cargo.toml b/xtask/bench/Cargo.toml index 82e94aef74a6..920d46213ce9 100644 --- a/xtask/bench/Cargo.toml +++ b/xtask/bench/Cargo.toml @@ -7,6 +7,8 @@ version = "0.0.0" [dependencies] biome_analyze = { workspace = true } biome_console = { workspace = true } +biome_css_parser = { workspace = true } +biome_css_syntax = { workspace = true } biome_diagnostics = { workspace = true } biome_formatter = { workspace = true } biome_js_analyze = { workspace = true } diff --git a/xtask/bench/src/language.rs b/xtask/bench/src/language.rs index d1859e502aa0..0a99413966aa 100644 --- a/xtask/bench/src/language.rs +++ b/xtask/bench/src/language.rs @@ -1,5 +1,6 @@ use crate::test_case::TestCase; use biome_analyze::{AnalysisFilter, AnalyzerOptions, ControlFlow, Never, RuleCategories}; +use biome_css_parser::CssParserOptions; use biome_formatter::{FormatResult, Formatted, PrintResult, Printed}; use biome_js_analyze::analyze; use biome_js_formatter::context::{JsFormatContext, JsFormatOptions}; @@ -15,6 +16,7 @@ use criterion::black_box; pub enum Parse<'a> { JavaScript(JsFileSource, &'a str), Json(&'a str), + Css(&'a str), } impl<'a> Parse<'a> { @@ -23,6 +25,7 @@ impl<'a> Parse<'a> { Ok(source_type) => Some(Parse::JavaScript(source_type, case.code())), Err(_) => match case.extension() { "json" => Some(Parse::Json(case.code())), + "css" => Some(Parse::Css(case.code())), _ => None, }, } @@ -38,6 +41,10 @@ impl<'a> Parse<'a> { code, JsonParserOptions::default(), )), + Parse::Css(code) => Parsed::Css(biome_css_parser::parse_css( + code, + CssParserOptions::default().with_allow_single_line_comments(), + )), } } @@ -57,6 +64,11 @@ impl<'a> Parse<'a> { cache, JsonParserOptions::default(), )), + Parse::Css(code) => Parsed::Css(biome_css_parser::parse_css_with_cache( + code, + cache, + CssParserOptions::default().with_allow_single_line_comments(), + )), } } } @@ -64,6 +76,7 @@ impl<'a> Parse<'a> { pub enum Parsed { JavaScript(biome_js_parser::Parse, JsFileSource), Json(biome_json_parser::JsonParse), + Css(biome_css_parser::CssParse), } impl Parsed { @@ -73,6 +86,7 @@ impl Parsed { Some(FormatNode::JavaScript(parse.syntax(), *source_type)) } Parsed::Json(parse) => Some(FormatNode::Json(parse.syntax())), + Parsed::Css(_) => None, } } @@ -80,6 +94,7 @@ impl Parsed { match self { Parsed::JavaScript(parse, _) => Some(Analyze::JavaScript(parse.tree())), Parsed::Json(_) => None, + Parsed::Css(_) => None, } } @@ -87,6 +102,7 @@ impl Parsed { match self { Parsed::JavaScript(parse, _) => parse.into_diagnostics(), Parsed::Json(parse) => parse.into_diagnostics(), + Parsed::Css(parse) => parse.into_diagnostics(), } } } diff --git a/xtask/bench/src/lib.rs b/xtask/bench/src/lib.rs index 34af22483b3e..2331a2983077 100644 --- a/xtask/bench/src/lib.rs +++ b/xtask/bench/src/lib.rs @@ -104,6 +104,7 @@ pub fn run(args: RunArgs) { all_suites.insert("js", include_str!("libs-js.txt")); all_suites.insert("ts", include_str!("libs-ts.txt")); all_suites.insert("json", include_str!("libs-json.txt")); + all_suites.insert("css", include_str!("libs-css.txt")); } let mut libs = vec![]; diff --git a/xtask/bench/src/libs-css.txt b/xtask/bench/src/libs-css.txt new file mode 100644 index 000000000000..f2c6acef8609 --- /dev/null +++ b/xtask/bench/src/libs-css.txt @@ -0,0 +1,8 @@ +https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css +https://cdn.jsdelivr.net/npm/daisyui@3.9.2/dist/full.css +https://cdn.jsdelivr.net/npm/purecss@3.0.0/build/pure-min.css +https://raw.githubusercontent.com/Dogfalo/materialize/v1-dev/dist/css/materialize.css +https://raw.githubusercontent.com/jgthms/bulma/master/css/bulma.css +https://raw.githubusercontent.com/foundation/foundation-sites/develop/dist/css/foundation.css +https://raw.githubusercontent.com/Semantic-Org/Semantic-UI/master/dist/semantic.css +https://raw.githubusercontent.com/tachyons-css/tachyons/main/css/tachyons.css