Skip to content

Commit

Permalink
Jemallocator was not being used where it should
Browse files Browse the repository at this point in the history
  • Loading branch information
Razican committed Apr 13, 2020
1 parent 02cfe9e commit c016b9d
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 13 deletions.
7 changes: 5 additions & 2 deletions boa/benches/exec.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
use boa::{exec, realm::Realm};
use criterion::{black_box, criterion_group, criterion_main, Criterion};

#[cfg_attr(target = "x86_64-unknown-linux-gnu", global_allocator)]
#[cfg(target = "x86_64-unknown-linux-gnu")]
#[cfg(all(target_arch = "x86_64", target_os = "linux", target_env = "gnu"))]
#[cfg_attr(
all(target_arch = "x86_64", target_os = "linux", target_env = "gnu"),
global_allocator
)]
static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc;

static SRC: &str = r#"
Expand Down
13 changes: 8 additions & 5 deletions boa/benches/fib.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
use boa::exec;
use criterion::{black_box, criterion_group, criterion_main, Criterion};

#[cfg_attr(target = "x86_64-unknown-linux-gnu", global_allocator)]
#[cfg(target = "x86_64-unknown-linux-gnu")]
#[cfg(all(target_arch = "x86_64", target_os = "linux", target_env = "gnu"))]
#[cfg_attr(
all(target_arch = "x86_64", target_os = "linux", target_env = "gnu"),
global_allocator
)]
static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc;

static SRC: &str = r#"
Expand All @@ -19,9 +22,9 @@ res;
"#;

fn fibonacci(c: &mut Criterion) {
c.bench_function("fibonacci (Execution)", move |b| {
b.iter(|| exec(black_box(SRC)))
});
c.bench_function("fibonacci (Execution)", move |b| {
b.iter(|| exec(black_box(SRC)))
});
}

criterion_group!(benches, fibonacci);
Expand Down
7 changes: 5 additions & 2 deletions boa/benches/parser.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
use boa::syntax::{lexer::Lexer, parser::Parser};
use criterion::{black_box, criterion_group, criterion_main, Criterion};

#[cfg_attr(target = "x86_64-unknown-linux-gnu", global_allocator)]
#[cfg(target = "x86_64-unknown-linux-gnu")]
#[cfg(all(target_arch = "x86_64", target_os = "linux", target_env = "gnu"))]
#[cfg_attr(
all(target_arch = "x86_64", target_os = "linux", target_env = "gnu"),
global_allocator
)]
static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc;

static EXPRESSION: &str = r#"
Expand Down
7 changes: 5 additions & 2 deletions boa/benches/string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@ use boa::{
};
use criterion::{black_box, criterion_group, criterion_main, Criterion};

#[cfg_attr(target = "x86_64-unknown-linux-gnu", global_allocator)]
#[cfg(target = "x86_64-unknown-linux-gnu")]
#[cfg(all(target_arch = "x86_64", target_os = "linux", target_env = "gnu"))]
#[cfg_attr(
all(target_arch = "x86_64", target_os = "linux", target_env = "gnu"),
global_allocator
)]
static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc;

static SRC: &str = "let foo = 'hello world!'; foo;";
Expand Down
7 changes: 5 additions & 2 deletions boa_cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,11 @@ use std::{
};
use structopt::{clap::arg_enum, StructOpt};

#[cfg_attr(target = "x86_64-unknown-linux-gnu", global_allocator)]
#[cfg(target = "x86_64-unknown-linux-gnu")]
#[cfg(all(target_arch = "x86_64", target_os = "linux", target_env = "gnu"))]
#[cfg_attr(
all(target_arch = "x86_64", target_os = "linux", target_env = "gnu"),
global_allocator
)]
static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc;

/// CLI configuration for Boa.
Expand Down

0 comments on commit c016b9d

Please sign in to comment.