Skip to main content

rustdom_x/
lib.rs

1#[macro_use]
2extern crate log;
3
4pub mod byte_string;
5pub mod common;
6pub mod hash;
7pub mod m128;
8pub mod memory;
9pub mod program;
10pub mod superscalar;
11pub mod vm;
12
13pub use crate::memory::VmMemory;
14pub use crate::vm::new_vm;
15
16#[test]
17fn test_hashing() {
18    use crate::memory::VmMemory;
19    use crate::vm::new_vm;
20    use std::sync::Arc;
21
22    let cache = Arc::new(VmMemory::full(b"test key 000"));
23    println!("Pre-faulting memory...");
24    {
25        let mut mem = cache.dataset_memory.write().unwrap();
26        for i in (0..mem.len()).step_by(512) { // step by page size
27            mem[i] = None; 
28        }
29    }
30    let mut vm = new_vm(cache);
31
32    for i in 0..10usize {
33        let hash = vm.calculate_hash(&vec![10u8; i * 1000]);
34        println!("{}, took: {}ms", hash.to_hex(), start.elapsed().as_millis());
35    }
36}