chore(ci): Fix codspeed benchmark (#9194)

This commit is contained in:
Donny/강동윤 2024-07-10 21:43:51 +09:00 committed by GitHub
parent be99ce0a57
commit e3eb197f00
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 14 additions and 24 deletions

View File

@ -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

View File

@ -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"
)
}
}
}

View File

@ -1,6 +1,6 @@
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;
@ -8,7 +8,7 @@ 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()),
@ -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)