From 2c2d9b3ead6ff6516bbed17c195f8f87b3f59c45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Nieto?= Date: Sat, 11 Nov 2023 14:36:05 +0100 Subject: [PATCH] fix(benchmarks): fixed criterion benchmark not compiling on windows due to jemalloc --- benchmarks/criterion/Cargo.toml | 2 ++ benchmarks/criterion/benches/sled.rs | 12 ++++-------- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/benchmarks/criterion/Cargo.toml b/benchmarks/criterion/Cargo.toml index 48e136f59..62d5e0efb 100644 --- a/benchmarks/criterion/Cargo.toml +++ b/benchmarks/criterion/Cargo.toml @@ -14,4 +14,6 @@ harness = false [dependencies] criterion = "0.3.0" sled = { path = "../.." } + +[target.'cfg(any(target_os = "linux", target_os = "macos"))'.dependencies] jemallocator = "0.3.2" diff --git a/benchmarks/criterion/benches/sled.rs b/benchmarks/criterion/benches/sled.rs index b5e3f5826..3e6331b38 100644 --- a/benchmarks/criterion/benches/sled.rs +++ b/benchmarks/criterion/benches/sled.rs @@ -1,15 +1,11 @@ use criterion::{criterion_group, criterion_main, Criterion}; -use jemallocator::Jemalloc; - use sled::Config; -#[cfg_attr( - // only enable jemalloc on linux and macos by default - any(target_os = "linux", target_os = "macos"), - global_allocator -)] -static ALLOC: Jemalloc = Jemalloc; +// only enable jemalloc on linux and macos by default +#[cfg(any(target_os = "linux", target_os = "macos"))] +#[global_allocator] +static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc; fn counter() -> usize { use std::sync::atomic::{AtomicUsize, Ordering::Relaxed};