Skip to content
Snippets Groups Projects
Unverified Commit 5f0d4df3 authored by Michael Müller's avatar Michael Müller
Browse files

Revert me: Add shallow benchmark for a first impression

parent a114df7d
No related merge requests found
......@@ -19,6 +19,7 @@
use log::trace;
use std::collections::HashMap;
use std::time::{Duration, Instant};
// The pointers need to be aligned to 8 bytes.
const ALIGNMENT: usize = 8;
......@@ -38,6 +39,7 @@ pub struct Heap {
heap: Vec<u8>,
max_heap_size: usize,
ptr_offset: usize,
start: Instant,
total_size: usize,
}
......@@ -56,6 +58,7 @@ impl Heap {
/// allocating memory.
///
pub fn new(mut ptr_offset: usize, heap_size: usize) -> Self {
eprintln!("Creating heap");
let padding = ptr_offset % ALIGNMENT;
if padding != 0 {
ptr_offset += ALIGNMENT - padding;
......@@ -68,6 +71,7 @@ impl Heap {
heap: vec![0; heap_size],
max_heap_size: heap_size,
ptr_offset,
start: Instant::now(),
total_size: 0,
}
}
......@@ -155,6 +159,13 @@ impl Heap {
}
impl Drop for Heap {
fn drop(&mut self) {
let duration = self.start.elapsed();
eprintln!("Dropping heap after {:?}", duration);
}
}
#[cfg(test)]
mod tests {
use super::*;
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment