Skip to content

Commit

Permalink
ci(transformer): enable unfinished plugins in benchmark
Browse files Browse the repository at this point in the history
  • Loading branch information
Dunqing committed Nov 2, 2024
1 parent 001058a commit d2b9343
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 8 deletions.
25 changes: 20 additions & 5 deletions crates/oxc_transformer/src/options/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ pub struct EnvOptions {

impl EnvOptions {
/// Explicitly enable all plugins that are ready, mainly for testing purposes.
pub fn enable_all() -> Self {
pub fn enable_all(include_unfinished_plugins: bool) -> Self {
Self {
regexp: RegExpOptions {
sticky_flag: true,
Expand All @@ -46,23 +46,38 @@ impl EnvOptions {
},
es2015: ES2015Options {
// Turned off because it is not ready.
arrow_function: None,
arrow_function: if include_unfinished_plugins {
Some(ArrowFunctionsOptions::default())
} else {
None
},
},
es2016: ES2016Options { exponentiation_operator: true },
es2017: ES2017Options {
// Turned off because it is not ready.
async_to_generator: false,
async_to_generator: include_unfinished_plugins,
},
es2018: ES2018Options {
// Turned off because it is not ready.
object_rest_spread: None,
object_rest_spread: if include_unfinished_plugins {
Some(ObjectRestSpreadOptions::default())
} else {
None
},
// Turned off because it is not ready.
async_generator_functions: false,
},
es2019: ES2019Options { optional_catch_binding: true },
es2020: ES2020Options { nullish_coalescing_operator: true },
es2021: ES2021Options { logical_assignment_operators: true },
es2022: ES2022Options { class_static_block: true, class_properties: None },
es2022: ES2022Options {
class_static_block: true,
class_properties: if include_unfinished_plugins {
Some(ClassPropertiesOptions::default())
} else {
None
},
},
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_transformer/src/options/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ impl TransformOptions {
refresh: Some(ReactRefreshOptions::default()),
..JsxOptions::default()
},
env: EnvOptions::enable_all(),
env: EnvOptions::enable_all(/* include_unfinished_plugins */ false),
helper_loader: HelperLoaderOptions {
mode: HelperLoaderMode::Runtime,
..Default::default()
Expand Down
7 changes: 5 additions & 2 deletions tasks/benchmark/benches/transformer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use oxc_parser::{Parser, ParserReturn};
use oxc_semantic::SemanticBuilder;
use oxc_span::SourceType;
use oxc_tasks_common::TestFiles;
use oxc_transformer::{TransformOptions, Transformer};
use oxc_transformer::{EnvOptions, TransformOptions, Transformer};

fn bench_transformer(criterion: &mut Criterion) {
let mut group = criterion.benchmark_group("transformer");
Expand Down Expand Up @@ -35,7 +35,10 @@ fn bench_transformer(criterion: &mut Criterion) {
.semantic
.into_symbol_table_and_scope_tree();

let options = TransformOptions::enable_all();
let mut options = TransformOptions::enable_all();
// Even the plugins are unfinished, we still want to enable all of them
// to track the performance changes during the development.
options.env = EnvOptions::enable_all(/* include_unfinished_plugins */ true);

runner.run(|| {
let ret = Transformer::new(&allocator, Path::new(&file.file_name), options)
Expand Down

0 comments on commit d2b9343

Please sign in to comment.