Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(ci): Fix codspeed benchmark #9194

Merged
merged 4 commits into from
Jul 10, 2024
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
2 changes: 1 addition & 1 deletion .github/workflows/bench.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ jobs:
bins: cargo-codspeed

- name: Build the benchmark target(s)
run: cargo codspeed build
run: cargo codspeed build --workspace --exclude swc_plugin_runner

- name: Run the benchmarks
uses: CodSpeedHQ/action@v2
Expand Down
26 changes: 6 additions & 20 deletions crates/swc_ecma_compat_es2015/src/classes/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -543,29 +543,15 @@ where
constructor = Some(c)
}
}
ClassMember::PrivateMethod(_) => unreachable!(
"classes pass: private method\nclass_properties pass should remove this"
),
ClassMember::Method(m) => methods.push(m),

ClassMember::ClassProp(..) => {
unreachable!("classes pass: property\nclass_properties pass should remove this")
}
ClassMember::PrivateProp(..) => unreachable!(
"classes pass: private property\nclass_properties pass should remove this"
),
ClassMember::TsIndexSignature(..) => {
// We just strip this.
}
ClassMember::PrivateMethod(_)
| ClassMember::ClassProp(..)
| ClassMember::PrivateProp(..)
| ClassMember::TsIndexSignature(..)
| ClassMember::StaticBlock(..)
| ClassMember::AutoAccessor(..) => {}
ClassMember::Empty(..) => {}
ClassMember::StaticBlock(..) => unreachable!(
"classes pass: static blocks\nstatic_blocks pass should remove this"
),
ClassMember::AutoAccessor(..) => {
unreachable!(
"classes pass: auto accessor \nauto_accesssors pass should remove this"
)
}
}
}

Expand Down
10 changes: 7 additions & 3 deletions crates/swc_ecma_transforms_typescript/benches/compat.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
use codspeed_criterion_compat::{black_box, criterion_group, criterion_main, Bencher, Criterion};
use swc_common::{chain, comments::SingleThreadedComments, sync::Lrc, FileName, Mark, SourceMap};
use swc_ecma_ast::Module;
use swc_ecma_ast::{Module, Program};
use swc_ecma_parser::{lexer::Lexer, Parser, StringInput, Syntax};
use swc_ecma_transforms_base::{helpers, resolver};
use swc_ecma_transforms_typescript::strip;
use swc_ecma_visit::{Fold, FoldWith};

static SOURCE: &str = include_str!("assets/AjaxObservable.ts");

fn module(cm: Lrc<SourceMap>) -> Module {
fn module(cm: Lrc<SourceMap>) -> Program {
let fm = cm.new_source_file(FileName::Anon, SOURCE.into());
let lexer = Lexer::new(
Syntax::Typescript(Default::default()),
Expand All @@ -18,7 +18,11 @@ fn module(cm: Lrc<SourceMap>) -> Module {
);
let mut parser = Parser::new_from(lexer);

parser.parse_module().map_err(|_| ()).unwrap()
parser
.parse_module()
.map(Program::Module)
.map_err(|_| ())
.unwrap()
}

fn run<V>(b: &mut Bencher, tr: impl Fn(Mark) -> V)
Expand Down
Loading