Compressing with lz4

This commit is contained in:
Piotrek
2021-05-10 13:30:15 +02:00
parent 3bd9fa942e
commit 4eaa0fab56
5 changed files with 76 additions and 44 deletions
+21 -17
View File
@@ -27,27 +27,31 @@ impl Game {
world: World::new("default".to_string())
};
// Try to load world from file
let timer = Instant::now();
for x in 0..64 {
for z in 0..64 {
let pos = &Point3{x,y:0,z};
let block = app.world.gen_block(pos);
content.write(pos, block);
if app.world.load() {
for (pos, block) in app.world.all_blocks() {
content.write(&pos, block);
}
println!("Loaded in {}", timer.elapsed().as_secs_f32());
}
// Generate new world
else {
let timer = Instant::now();
for x in 0..32 {
for z in 0..32 {
let pos = &Point3{x,y:0,z};
let block = app.world.gen_block(pos);
content.write(pos, block);
}
}
println!("Generated in {}", timer.elapsed().as_secs_f32());
let timer = Instant::now();
app.world.save();
println!("Saved in {}", timer.elapsed().as_secs_f32());
}
println!("Generated in {}", timer.elapsed().as_secs_f32());
let timer = Instant::now();
app.world.save();
println!("Saved in {}", timer.elapsed().as_secs_f32());
// let timer = Instant::now();
// app.world.load();
// for (pos, block) in app.world.all_blocks() {
// content.write(&pos, block);
// }
// println!("Loaded in {}", timer.elapsed().as_secs_f32());
println!("App initialized");
app