File: main.rs

package info (click to toggle)
rust-vm-memory 0.16.1-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 884 kB
  • sloc: makefile: 2
file content (48 lines) | stat: -rw-r--r-- 1,377 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
//
// SPDX-License-Identifier: Apache-2.0 OR BSD-3-Clause
/*
extern crate criterion;

pub use criterion::{black_box, criterion_group, criterion_main, Criterion};
#[cfg(feature = "backend-mmap")]
use vm_memory::{GuestAddress, GuestMemoryMmap};

mod guest_memory;
mod mmap;
mod volatile;

use volatile::benchmark_for_volatile;

#[cfg(feature = "backend-mmap")]
// Use this function with caution. It does not check against overflows
// and `GuestMemoryMmap::from_ranges` errors.
fn create_guest_memory_mmap(size: usize, count: u64) -> GuestMemoryMmap<()> {
    let mut regions: Vec<(GuestAddress, usize)> = Vec::new();
    for i in 0..count {
        regions.push((GuestAddress(i * size as u64), size));
    }

    GuestMemoryMmap::from_ranges(regions.as_slice()).unwrap()
}

pub fn criterion_benchmark(_c: &mut Criterion) {
    #[cfg(feature = "backend-mmap")]
    mmap::benchmark_for_mmap(_c);
}

pub fn benchmark_guest_memory(_c: &mut Criterion) {
    #[cfg(feature = "backend-mmap")]
    guest_memory::benchmark_for_guest_memory(_c)
}

criterion_group! {
    name = benches;
    config = Criterion::default().sample_size(200).measurement_time(std::time::Duration::from_secs(50));
    targets = criterion_benchmark, benchmark_guest_memory, benchmark_for_volatile
}

criterion_main! {
    benches,
}
*/