2020-06-09 13:45:00 +05:30
|
|
|
use std::error::Error;
|
2020-07-27 20:23:42 +05:30
|
|
|
use std::path::Path;
|
|
|
|
use std::time::{Duration, Instant};
|
|
|
|
use std::thread;
|
|
|
|
use std::sync::{Arc, Mutex};
|
2020-06-09 13:45:00 +05:30
|
|
|
|
2020-07-27 20:23:42 +05:30
|
|
|
use crate::block_manager::{Block, IoEngine, SyncIoEngine, BLOCK_SIZE};
|
2020-06-09 13:45:00 +05:30
|
|
|
|
2020-07-27 20:23:42 +05:30
|
|
|
pub fn check(dev: &Path) -> Result<(), Box<dyn Error>> {
|
|
|
|
let mut engine = SyncIoEngine::new(dev)?;
|
|
|
|
let count = 4096;
|
2020-06-09 13:45:00 +05:30
|
|
|
|
2020-07-27 20:23:42 +05:30
|
|
|
let mut blocks = Vec::new();
|
|
|
|
for n in 0..count {
|
|
|
|
blocks.push(Block::new(n));
|
2020-06-09 13:45:00 +05:30
|
|
|
}
|
|
|
|
|
2020-07-27 20:23:42 +05:30
|
|
|
let now = Instant::now();
|
|
|
|
engine.read(&mut blocks)?;
|
|
|
|
println!("read {} blocks in {} ms", count, now.elapsed().as_millis());
|
|
|
|
|
2020-06-09 13:45:00 +05:30
|
|
|
Ok(())
|
|
|
|
}
|