mirror of
https://github.com/swc-project/swc.git
synced 2024-11-23 09:38:16 +03:00
chore(plugin/runner): Fix benchmark (#9477)
Some checks are pending
CI / Cargo fmt (push) Waiting to run
CI / Cargo clippy (push) Waiting to run
CI / Check license of dependencies (push) Waiting to run
CI / Check (macos-latest) (push) Waiting to run
CI / Check (ubuntu-latest) (push) Waiting to run
CI / Check (windows-latest) (push) Waiting to run
CI / Test wasm (binding_core_wasm) (push) Waiting to run
CI / Test wasm (binding_minifier_wasm) (push) Waiting to run
CI / Test wasm (binding_typescript_wasm) (push) Waiting to run
CI / List crates (push) Waiting to run
CI / Test - ${{ matrix.settings.crate }} - ${{ matrix.settings.os }} (push) Blocked by required conditions
CI / Test node bindings - ${{ matrix.os }} (macos-latest) (push) Waiting to run
CI / Test node bindings - ${{ matrix.os }} (windows-latest) (push) Waiting to run
CI / Test with @swc/cli (push) Waiting to run
CI / Miri (better_scoped_tls) (push) Waiting to run
CI / Miri (string_enum) (push) Waiting to run
CI / Miri (swc) (push) Waiting to run
CI / Miri (swc_bundler) (push) Waiting to run
CI / Miri (swc_ecma_codegen) (push) Waiting to run
CI / Miri (swc_ecma_minifier) (push) Waiting to run
CI / Done (push) Blocked by required conditions
Benchmark / Bench everything (push) Waiting to run
Some checks are pending
CI / Cargo fmt (push) Waiting to run
CI / Cargo clippy (push) Waiting to run
CI / Check license of dependencies (push) Waiting to run
CI / Check (macos-latest) (push) Waiting to run
CI / Check (ubuntu-latest) (push) Waiting to run
CI / Check (windows-latest) (push) Waiting to run
CI / Test wasm (binding_core_wasm) (push) Waiting to run
CI / Test wasm (binding_minifier_wasm) (push) Waiting to run
CI / Test wasm (binding_typescript_wasm) (push) Waiting to run
CI / List crates (push) Waiting to run
CI / Test - ${{ matrix.settings.crate }} - ${{ matrix.settings.os }} (push) Blocked by required conditions
CI / Test node bindings - ${{ matrix.os }} (macos-latest) (push) Waiting to run
CI / Test node bindings - ${{ matrix.os }} (windows-latest) (push) Waiting to run
CI / Test with @swc/cli (push) Waiting to run
CI / Miri (better_scoped_tls) (push) Waiting to run
CI / Miri (string_enum) (push) Waiting to run
CI / Miri (swc) (push) Waiting to run
CI / Miri (swc_bundler) (push) Waiting to run
CI / Miri (swc_ecma_codegen) (push) Waiting to run
CI / Miri (swc_ecma_minifier) (push) Waiting to run
CI / Done (push) Blocked by required conditions
Benchmark / Bench everything (push) Waiting to run
This commit is contained in:
parent
4bee30ab40
commit
b0b5e36675
@ -1,5 +0,0 @@
|
||||
|
||||
|
||||
class Foo {
|
||||
|
||||
}
|
@ -19,7 +19,7 @@ use swc_common::{
|
||||
use swc_ecma_ast::EsVersion;
|
||||
use swc_ecma_parser::parse_file_as_program;
|
||||
|
||||
static SOURCE: &str = include_str!("./assets/input.js");
|
||||
static SOURCE: &str = include_str!("../../swc_ecma_minifier/benches/full/typescript.js");
|
||||
|
||||
fn plugin_group(c: &mut Criterion) {
|
||||
let plugin_dir = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap())
|
||||
@ -65,49 +65,52 @@ fn bench_transform(b: &mut Bencher, plugin_dir: &Path) {
|
||||
#[cfg(feature = "__rkyv")]
|
||||
b.iter(|| {
|
||||
GLOBALS.set(&Globals::new(), || {
|
||||
let cm = Arc::new(SourceMap::new(FilePathMapping::empty()));
|
||||
tokio::runtime::Runtime::new().unwrap().block_on(async {
|
||||
let cm = Arc::new(SourceMap::new(FilePathMapping::empty()));
|
||||
|
||||
let fm = cm.new_source_file(
|
||||
FileName::Real("src/test.ts".into()).into(),
|
||||
SOURCE.to_string(),
|
||||
);
|
||||
let fm = cm.new_source_file(
|
||||
FileName::Real("src/test.ts".into()).into(),
|
||||
SOURCE.to_string(),
|
||||
);
|
||||
|
||||
let program = parse_file_as_program(
|
||||
&fm,
|
||||
Default::default(),
|
||||
EsVersion::latest(),
|
||||
None,
|
||||
&mut Vec::new(),
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
let program = VersionedSerializable::new(program);
|
||||
let program_ser = PluginSerializedBytes::try_serialize(&program).unwrap();
|
||||
|
||||
let mut transform_plugin_executor = swc_plugin_runner::create_plugin_transform_executor(
|
||||
&cm,
|
||||
&Mark::new(),
|
||||
&Arc::new(TransformPluginMetadataContext::new(
|
||||
let program = parse_file_as_program(
|
||||
&fm,
|
||||
Default::default(),
|
||||
EsVersion::latest(),
|
||||
None,
|
||||
"development".to_string(),
|
||||
None,
|
||||
)),
|
||||
Box::new(plugin_module.clone()),
|
||||
None,
|
||||
None,
|
||||
);
|
||||
|
||||
let experimental_metadata: VersionedSerializable<AHashMap<String, String>> =
|
||||
VersionedSerializable::new(AHashMap::default());
|
||||
let _experimental_metadata =
|
||||
PluginSerializedBytes::try_serialize(&experimental_metadata)
|
||||
.expect("Should be a hashmap");
|
||||
|
||||
let res = transform_plugin_executor
|
||||
.transform(&program_ser, Some(true))
|
||||
&mut Vec::new(),
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
let _ = black_box(res);
|
||||
let program = VersionedSerializable::new(program);
|
||||
let program_ser = PluginSerializedBytes::try_serialize(&program).unwrap();
|
||||
|
||||
let mut transform_plugin_executor =
|
||||
swc_plugin_runner::create_plugin_transform_executor(
|
||||
&cm,
|
||||
&Mark::new(),
|
||||
&Arc::new(TransformPluginMetadataContext::new(
|
||||
None,
|
||||
"development".to_string(),
|
||||
None,
|
||||
)),
|
||||
Box::new(plugin_module.clone()),
|
||||
None,
|
||||
None,
|
||||
);
|
||||
|
||||
let experimental_metadata: VersionedSerializable<AHashMap<String, String>> =
|
||||
VersionedSerializable::new(AHashMap::default());
|
||||
let _experimental_metadata =
|
||||
PluginSerializedBytes::try_serialize(&experimental_metadata)
|
||||
.expect("Should be a hashmap");
|
||||
|
||||
let res = transform_plugin_executor
|
||||
.transform(&program_ser, Some(true))
|
||||
.unwrap();
|
||||
|
||||
let _ = black_box(res);
|
||||
});
|
||||
});
|
||||
})
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user