Skip to content

Commit 2bd338a

Browse files
committed
fix: only try file-based benches if rawfd feature is enabled
Without that feature, we do not have ReadVolatile/WriteVolatile impls for File, which the benches depend on. Signed-off-by: Patrick Roy <[email protected]>
1 parent e29f79f commit 2bd338a

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

benches/mmap/mod.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,11 @@
77
extern crate criterion;
88
extern crate vm_memory;
99

10+
#[cfg(feature = "rawfd")]
1011
use std::fs::{File, OpenOptions};
1112
use std::mem::size_of;
13+
14+
#[cfg(feature = "rawfd")]
1215
use std::path::Path;
1316

1417
use core::hint::black_box;
@@ -84,7 +87,10 @@ pub fn benchmark_for_mmap(c: &mut Criterion) {
8487

8588
let mut image = make_image(ACCESS_SIZE);
8689
let buf = &mut [0u8; ACCESS_SIZE];
90+
91+
#[cfg(feature = "rawfd")]
8792
let mut file = File::open(Path::new("/dev/zero")).expect("Could not open /dev/zero");
93+
#[cfg(feature = "rawfd")]
8894
let mut file_to_write = OpenOptions::new()
8995
.write(true)
9096
.open("/dev/null")
@@ -110,6 +116,7 @@ pub fn benchmark_for_mmap(c: &mut Criterion) {
110116
})
111117
});
112118

119+
#[cfg(feature = "rawfd")]
113120
c.bench_function(format!("read_from_file_{:#0X}", offset).as_str(), |b| {
114121
b.iter(|| {
115122
black_box(&memory)
@@ -159,6 +166,7 @@ pub fn benchmark_for_mmap(c: &mut Criterion) {
159166
})
160167
});
161168

169+
#[cfg(feature = "rawfd")]
162170
c.bench_function(format!("write_to_file_{:#0X}", offset).as_str(), |b| {
163171
b.iter(|| {
164172
black_box(&memory)

0 commit comments

Comments
 (0)