Handle properly multi core
This commit is contained in:
parent
9a1d0837fa
commit
7b8dec570f
@ -35,18 +35,22 @@ fn run_benchmark<T: CovertChannel + 'static>(
|
|||||||
constructor: impl Fn(usize, usize) -> T,
|
constructor: impl Fn(usize, usize) -> T,
|
||||||
num_iter: usize,
|
num_iter: usize,
|
||||||
num_pages: usize,
|
num_pages: usize,
|
||||||
|
old: CpuSet,
|
||||||
) -> BenchmarkStats {
|
) -> BenchmarkStats {
|
||||||
let mut results = Vec::new();
|
let mut results = Vec::new();
|
||||||
print!("Benchmarking {} with {} pages", name, num_pages);
|
print!("Benchmarking {} with {} pages", name, num_pages);
|
||||||
let old = sched_getaffinity(Pid::from_raw(0)).unwrap();
|
let mut count = 0;
|
||||||
for i in 0..CpuSet::count() {
|
for i in 0..CpuSet::count() {
|
||||||
for j in 0..CpuSet::count() {
|
for j in 0..CpuSet::count() {
|
||||||
for _ in 0..num_iter {
|
if old.is_set(i).unwrap() && old.is_set(j).unwrap() && i != j {
|
||||||
print!(".");
|
for _ in 0..num_iter {
|
||||||
stdout().flush().expect("Failed to flush");
|
count += 1;
|
||||||
let channel = constructor(i, j);
|
print!(".");
|
||||||
let r = benchmark_channel(channel, num_pages, NUM_BYTES);
|
stdout().flush().expect("Failed to flush");
|
||||||
results.push(r);
|
let channel = constructor(i, j);
|
||||||
|
let r = benchmark_channel(channel, num_pages, NUM_BYTES);
|
||||||
|
results.push(r);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -61,9 +65,9 @@ fn run_benchmark<T: CovertChannel + 'static>(
|
|||||||
average_C += result.capacity();
|
average_C += result.capacity();
|
||||||
average_T += result.true_capacity()
|
average_T += result.true_capacity()
|
||||||
}
|
}
|
||||||
average_p /= num_iter as f64;
|
average_p /= count as f64;
|
||||||
average_C /= num_iter as f64;
|
average_C /= count as f64;
|
||||||
average_T /= num_iter as f64;
|
average_T /= count as f64;
|
||||||
println!(
|
println!(
|
||||||
"{} - {} Average p: {} C: {}, T: {}",
|
"{} - {} Average p: {} C: {}, T: {}",
|
||||||
name, num_pages, average_p, average_C, average_T
|
name, num_pages, average_p, average_C, average_T
|
||||||
@ -79,9 +83,9 @@ fn run_benchmark<T: CovertChannel + 'static>(
|
|||||||
let T = result.true_capacity() - average_T;
|
let T = result.true_capacity() - average_T;
|
||||||
var_T += T * T;
|
var_T += T * T;
|
||||||
}
|
}
|
||||||
var_p /= num_iter as f64;
|
var_p /= count as f64;
|
||||||
var_C /= num_iter as f64;
|
var_C /= count as f64;
|
||||||
var_T /= num_iter as f64;
|
var_T /= count as f64;
|
||||||
println!(
|
println!(
|
||||||
"{} - {} Variance of p: {}, C: {}, T:{}",
|
"{} - {} Variance of p: {}, C: {}, T:{}",
|
||||||
name, num_pages, var_p, var_C, var_T
|
name, num_pages, var_p, var_C, var_T
|
||||||
@ -98,6 +102,8 @@ fn run_benchmark<T: CovertChannel + 'static>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
let old = sched_getaffinity(Pid::from_raw(0)).unwrap();
|
||||||
|
|
||||||
for num_pages in 1..=32 {
|
for num_pages in 1..=32 {
|
||||||
let naive_ff = run_benchmark(
|
let naive_ff = run_benchmark(
|
||||||
"Naive F+F",
|
"Naive F+F",
|
||||||
@ -108,6 +114,7 @@ fn main() {
|
|||||||
},
|
},
|
||||||
NUM_ITER,
|
NUM_ITER,
|
||||||
num_pages,
|
num_pages,
|
||||||
|
old,
|
||||||
);
|
);
|
||||||
|
|
||||||
let fr = run_benchmark(
|
let fr = run_benchmark(
|
||||||
@ -119,6 +126,7 @@ fn main() {
|
|||||||
},
|
},
|
||||||
NUM_ITER,
|
NUM_ITER,
|
||||||
num_pages,
|
num_pages,
|
||||||
|
old,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user