added timer

This commit is contained in:
2023-01-30 00:34:04 +01:00
parent 5d879f8a1e
commit b27c90195a
2 changed files with 508 additions and 503 deletions

1002
img.ppm

File diff suppressed because one or more lines are too long

View File

@@ -7,7 +7,7 @@ pub mod hittable_list;
pub mod rtweekend;
pub mod camera;
use std::{io::{BufWriter, Write}, fs::File};
use std::{io::{BufWriter, Write}, fs::File, time::Instant};
use crate::{
color::*,
@@ -57,6 +57,7 @@ fn main() {
// Render
//let mut rng = rand::thread_rng();
let now = Instant::now();
let mut file = BufWriter::new(File::create("img.ppm").expect("File creation failed"));
write!(file, "P3\n{image_width} {image_height}\n255").expect("Error while writing Magic Byte");
@@ -78,4 +79,8 @@ fn main() {
println!("[ {:.2} % ]", (1.0 - ((j + 1) as f64 / image_width as f64)) * 100.0);
}
}
println!("Took {:.6}ms", now.elapsed().as_millis());
println!("Took {:.6}s", now.elapsed().as_secs_f64());
println!("Took {:.6}m", now.elapsed().as_secs_f64() / 60.0);
println!("Took {:.6}h", now.elapsed().as_secs_f64() / 3600.0);
}