Skip to content

Commit

Permalink
chore(ci): Fix codspeed benchmark (#9194)
Browse files Browse the repository at this point in the history
  • Loading branch information
kdy1 committed Jul 10, 2024
1 parent be99ce0 commit e3eb197
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 24 deletions.
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

0 comments on commit e3eb197

Please sign in to comment.