Skip to content

Commit

Permalink
Use swc alloc
Browse files Browse the repository at this point in the history
  • Loading branch information
kdy1 committed Jul 19, 2024
1 parent c601532 commit 35dac29
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion crates/swc_ecma_codegen/benches/bench.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
extern crate swc_malloc;

use codspeed_criterion_compat::{black_box, criterion_group, criterion_main, Bencher, Criterion};
use swc_allocator::maybe::vec::Vec;
use swc_allocator::{maybe::vec::Vec, Allocator};
use swc_common::FileName;
use swc_ecma_codegen::Emitter;
use swc_ecma_parser::{Parser, StringInput, Syntax};
Expand Down Expand Up @@ -95,6 +95,9 @@ fn bench_emitter(b: &mut Bencher, s: &str) {
}

b.iter(|| {
let allocator = Allocator::default();
let _guard = unsafe { allocator.guard() };

let mut src_map_buf = Vec::new();
let mut buf = Vec::new();
{
Expand Down
5 changes: 4 additions & 1 deletion crates/swc_ecma_codegen/benches/with_parse.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
extern crate swc_malloc;

use codspeed_criterion_compat::{black_box, criterion_group, criterion_main, Bencher, Criterion};
use swc_allocator::maybe::vec::Vec;
use swc_allocator::{maybe::vec::Vec, Allocator};
use swc_common::FileName;
use swc_ecma_codegen::Emitter;
use swc_ecma_parser::{Parser, StringInput, Syntax};
Expand Down Expand Up @@ -83,6 +83,9 @@ const LARGE_PARTIAL_JS: &str = include_str!("large-partial.js");
fn bench_emitter(b: &mut Bencher, s: &str) {
let _ = ::testing::run_test(true, |cm, handler| {
b.iter(|| {
let allocator = Allocator::default();
let _guard = unsafe { allocator.guard() };

let fm = cm.new_source_file(FileName::Anon.into(), s.into());
let mut parser = Parser::new(Syntax::default(), StringInput::from(&*fm), None);
let module = parser
Expand Down

0 comments on commit 35dac29

Please sign in to comment.