fixed offset being way off
This commit is contained in:
parent
1573de227c
commit
42fbe81ecb
1 changed files with 15 additions and 12 deletions
27
src/main.rs
27
src/main.rs
|
@ -33,25 +33,26 @@ fn large_random_file_generation(path: String) {
|
||||||
|
|
||||||
fn _large_random_file_generation_helper(i: &u64, out: Arc<Mutex<Result<File, Error>>>) {
|
fn _large_random_file_generation_helper(i: &u64, out: Arc<Mutex<Result<File, Error>>>) {
|
||||||
let mut rng = XorShiftRng::seed_from_u64(2484345508);
|
let mut rng = XorShiftRng::seed_from_u64(2484345508);
|
||||||
let block_size = 1310720;
|
|
||||||
// NOTE: update this both here and in `large_random_file_generation()`
|
// NOTE: update this both here and in `large_random_file_generation()`
|
||||||
let num_threads = 12;
|
let num_threads = 12;
|
||||||
let mut data = [0u8; 1310720];
|
let mut data = [0u8; 1310720];
|
||||||
|
let block_size = 1310720;
|
||||||
|
|
||||||
// enter desired size in bytes, must be a multiple of 655360
|
// enter desired size in bytes, must be a multiple of 655360
|
||||||
// this is not a typo, the extra zero after 65536is for the threads
|
// this is not a typo, the extra zero after 65536is for the threads
|
||||||
// 26843545600 = 25 GiB
|
// 26843545600 = 25 GiB
|
||||||
let blocks_per_thread: u64 = 26843545600 / (block_size * num_threads);
|
let blocks_per_thread: u64 = 26843545600 / (block_size * num_threads);
|
||||||
|
println!("{}", i);
|
||||||
for u in (i * blocks_per_thread)..((i + 1) * blocks_per_thread) {
|
for u in (i * blocks_per_thread)..((i + 1) * blocks_per_thread) {
|
||||||
rng.fill_bytes(&mut data);
|
rng.fill_bytes(&mut data);
|
||||||
|
|
||||||
let offset: u64 = (i * blocks_per_thread * 1310720) + (1310720 * u);
|
//let offset: u64 = (i * blocks_per_thread * 1310720) + (1310720 * u);
|
||||||
|
let offset: u64 = u * block_size;
|
||||||
let mut out = out.lock().unwrap();
|
let mut out = out.lock().unwrap();
|
||||||
out.as_mut().unwrap().write_all_at(&data, offset);
|
out.as_mut().unwrap().write_all_at(&data, offset);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fn single_threaded_large_random_file_generation(path: String) {
|
fn single_threaded_large_random_file_generation(path: String) {
|
||||||
let mut out = File::create(path).unwrap();
|
let mut out = File::create(path).unwrap();
|
||||||
let mut rng = XorShiftRng::seed_from_u64(2484345508);
|
let mut rng = XorShiftRng::seed_from_u64(2484345508);
|
||||||
|
@ -62,7 +63,6 @@ fn single_threaded_large_random_file_generation(path: String) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fn small_random_files_generation(folder: String) {
|
fn small_random_files_generation(folder: String) {
|
||||||
let mut rng = XorShiftRng::seed_from_u64(2484345508);
|
let mut rng = XorShiftRng::seed_from_u64(2484345508);
|
||||||
let mut data = [0u8; 1024];
|
let mut data = [0u8; 1024];
|
||||||
|
@ -88,19 +88,22 @@ fn grab_kernel(folder: String) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// i'm too lazy to do this in rust
|
// i'm too lazy to do this in rust
|
||||||
println!("{:?}", Command::new("tar")
|
println!(
|
||||||
.arg("-xvf")
|
"{:?}",
|
||||||
.arg("data/kernel/kernel.tar.xz")
|
Command::new("tar")
|
||||||
.arg("--one-top-level")
|
.arg("-xvf")
|
||||||
.current_dir("data/kernel/")
|
.arg("data/kernel/kernel.tar.xz")
|
||||||
.output()
|
.arg("--one-top-level")
|
||||||
.unwrap());
|
.current_dir("data/kernel/")
|
||||||
|
.output()
|
||||||
|
.unwrap()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
large_random_file_generation("data/25G-random.bin".to_string());
|
large_random_file_generation("data/25G-random.bin".to_string());
|
||||||
//single_threaded_large_random_file_generation("data/output".to_string())
|
//single_threaded_large_random_file_generation("data/output".to_string())
|
||||||
|
|
||||||
//small_random_files_generation("data/small-files/random".to_string());
|
//small_random_files_generation("data/small-files/random".to_string());
|
||||||
//grab_kernel("data/kernel".to_string());
|
//grab_kernel("data/kernel".to_string());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue