added timer
This commit is contained in:
@@ -7,7 +7,7 @@ pub mod hittable_list;
|
|||||||
pub mod rtweekend;
|
pub mod rtweekend;
|
||||||
pub mod camera;
|
pub mod camera;
|
||||||
|
|
||||||
use std::{io::{BufWriter, Write}, fs::File};
|
use std::{io::{BufWriter, Write}, fs::File, time::Instant};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
color::*,
|
color::*,
|
||||||
@@ -57,6 +57,7 @@ fn main() {
|
|||||||
|
|
||||||
// Render
|
// Render
|
||||||
//let mut rng = rand::thread_rng();
|
//let mut rng = rand::thread_rng();
|
||||||
|
let now = Instant::now();
|
||||||
let mut file = BufWriter::new(File::create("img.ppm").expect("File creation failed"));
|
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");
|
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!("[ {:.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);
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user