diff --git a/covert_channels_benchmark/src/main.rs b/covert_channels_benchmark/src/main.rs index a570223..ed13b91 100644 --- a/covert_channels_benchmark/src/main.rs +++ b/covert_channels_benchmark/src/main.rs @@ -40,23 +40,35 @@ fn run_benchmark( num_iter: usize, num_pages: usize, old: CpuSet, + iterate_cores: bool, ) -> BenchmarkStats { let mut results = Vec::new(); print!("Benchmarking {} with {} pages", name, num_pages); let mut count = 0; - for i in 0..CpuSet::count() { - for j in 0..CpuSet::count() { - if old.is_set(i).unwrap() && old.is_set(j).unwrap() && i != j { - for _ in 0..num_iter { - count += 1; - print!("."); - stdout().flush().expect("Failed to flush"); - let (channel, main_core, helper_core) = constructor(i, j); - let r = benchmark_channel(channel, num_pages, NUM_BYTES); - results.push((r, main_core, helper_core)); + if iterate_cores { + for i in 0..CpuSet::count() { + for j in 0..CpuSet::count() { + if old.is_set(i).unwrap() && old.is_set(j).unwrap() && i != j { + for _ in 0..num_iter { + count += 1; + print!("."); + stdout().flush().expect("Failed to flush"); + let (channel, main_core, helper_core) = constructor(i, j); + let r = benchmark_channel(channel, num_pages, NUM_BYTES); + results.push((r, main_core, helper_core)); + } } } } + } else { + for _ in 0..num_iter { + count += 1; + print!("."); + stdout().flush().expect("Failed to flush"); + let (channel, main_core, helper_core) = constructor(0, 0); + let r = benchmark_channel(channel, num_pages, NUM_BYTES); + results.push((r, main_core, helper_core)); + } } println!(); let mut average_p = 0.0; @@ -149,6 +161,7 @@ fn main() { NUM_ITER, num_pages, old, + true, ); let naive_fr = run_benchmark( @@ -158,12 +171,14 @@ fn main() { bucket_index: 250, miss_faster_than_hit: false, }); + r.set_cores(i, j); (r, i, j) }, NUM_ITER, num_pages, old, + true, ); let ff = run_benchmark( @@ -179,9 +194,10 @@ fn main() { }; (r, i, j) }, - 1, + NUM_ITER, num_pages, old, + false, ); let fr = run_benchmark( @@ -197,9 +213,10 @@ fn main() { }; (r, i, j) }, - 1, + NUM_ITER, num_pages, old, + false, ); } }