Skip to content

Commit 0729e9c

Browse files
committed
fix: only try file-based benches if rawfd feature is enables
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 972cf8b commit 0729e9c

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

benches/mmap/mod.rs

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

10+
11+
#[cfg(feature = "rawfd")]
1012
use std::fs::{File, OpenOptions};
1113
use std::mem::size_of;
14+
15+
#[cfg(feature = "rawfd")]
1216
use std::path::Path;
1317

1418
use core::hint::black_box;
@@ -84,7 +88,10 @@ pub fn benchmark_for_mmap(c: &mut Criterion) {
8488

8589
let mut image = make_image(ACCESS_SIZE);
8690
let buf = &mut [0u8; ACCESS_SIZE];
91+
92+
#[cfg(feature = "rawfd")]
8793
let mut file = File::open(Path::new("/dev/zero")).expect("Could not open /dev/zero");
94+
#[cfg(feature = "rawfd")]
8895
let mut file_to_write = OpenOptions::new()
8996
.write(true)
9097
.open("/dev/null")
@@ -110,6 +117,7 @@ pub fn benchmark_for_mmap(c: &mut Criterion) {
110117
})
111118
});
112119

120+
#[cfg(feature = "rawfd")]
113121
c.bench_function(format!("read_from_file_{:#0X}", offset).as_str(), |b| {
114122
b.iter(|| {
115123
black_box(&memory)
@@ -159,6 +167,8 @@ pub fn benchmark_for_mmap(c: &mut Criterion) {
159167
})
160168
});
161169

170+
171+
#[cfg(feature = "rawfd")]
162172
c.bench_function(format!("write_to_file_{:#0X}", offset).as_str(), |b| {
163173
b.iter(|| {
164174
black_box(&memory)

0 commit comments

Comments
 (0)