Print human friendly rays / second.
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
This commit is contained in:
@@ -36,8 +36,7 @@ lazy_static! {
|
||||
|
||||
#[cfg(not(feature = "prom"))]
|
||||
fn push_metrics(_push_gateway_addr: &str, _instance: String, start_time: &DateTime<Utc>) {
|
||||
let runtime = *start_time - Utc::now();
|
||||
let runtime = runtime.to_std().unwrap();
|
||||
let runtime = (Utc::now() - *start_time).to_std().unwrap();
|
||||
info!(
|
||||
"Render time {}.{} seconds",
|
||||
runtime.as_secs(),
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/// From https://raw.githubusercontent.com/BobGneu/human-format-rs/master/src/lib.rs
|
||||
#![doc(html_root_url = "https://docs.rs/human_format")]
|
||||
|
||||
//! From https://raw.githubusercontent.com/BobGneu/human-format-rs/master/src/lib.rs
|
||||
//! `human_format` provides facilitates creating a formatted string, converting between numbers that are beyond typical
|
||||
//! needs for humans into a simpler string that conveys the gist of the meaning of the number.
|
||||
//!
|
||||
|
||||
@@ -6,6 +6,7 @@ pub mod cuboid;
|
||||
pub mod flip_normals;
|
||||
pub mod hitable;
|
||||
pub mod hitable_list;
|
||||
mod human;
|
||||
pub mod kdtree;
|
||||
pub mod material;
|
||||
pub mod moving_sphere;
|
||||
|
||||
@@ -23,6 +23,7 @@ use rand::Rng;
|
||||
|
||||
use crate::camera::Camera;
|
||||
use crate::hitable::Hit;
|
||||
use crate::human;
|
||||
use crate::ray::Ray;
|
||||
use crate::scenes;
|
||||
use crate::texture::EnvMap;
|
||||
@@ -42,6 +43,7 @@ impl MockPrometheus {
|
||||
fn inc(&self) {}
|
||||
}
|
||||
|
||||
static RAY_COUNT: AtomicUsize = AtomicUsize::new(0);
|
||||
#[cfg(not(feature = "prom"))]
|
||||
static RAY_COUNTER: MockPrometheus = MockPrometheus {};
|
||||
|
||||
@@ -194,6 +196,7 @@ fn color(
|
||||
global_illumination: bool,
|
||||
env_map: &Option<EnvMap>,
|
||||
) -> Vec3 {
|
||||
RAY_COUNT.fetch_add(1, Ordering::SeqCst);
|
||||
RAY_COUNTER.with_label_values(&[&depth.to_string()]).inc();
|
||||
if let Some(rec) = world.hit(r, 0.001, std::f32::MAX) {
|
||||
let (u, v) = rec.uv;
|
||||
@@ -284,7 +287,7 @@ fn render_worker(
|
||||
let job = { input_chan.lock().unwrap().recv() };
|
||||
match job {
|
||||
Err(err) => {
|
||||
info!("Shutting down render_worker {}: {}", tid, err);
|
||||
trace!("Shutting down render_worker {}: {}", tid, err);
|
||||
return;
|
||||
}
|
||||
Ok(req) => match req {
|
||||
@@ -301,7 +304,6 @@ fn render_worker(
|
||||
},
|
||||
}
|
||||
}
|
||||
trace!(target: "renderer", "Shutting down worker {}", tid);
|
||||
}
|
||||
|
||||
pub fn render(scene: Scene, output_dir: &Path) -> std::result::Result<(), std::io::Error> {
|
||||
@@ -344,22 +346,28 @@ pub fn render(scene: Scene, output_dir: &Path) -> std::result::Result<(), std::i
|
||||
thread::spawn(move || {
|
||||
let mut last_time = time::Instant::now();
|
||||
let mut last_pixel_count = PIXEL_COUNT.load(Ordering::SeqCst);
|
||||
let mut last_ray_count = RAY_COUNT.load(Ordering::SeqCst);
|
||||
let human = human::Formatter::new();
|
||||
loop {
|
||||
let sleep_time = time::Duration::from_secs(1);
|
||||
thread::sleep(sleep_time);
|
||||
let now = time::Instant::now();
|
||||
let mut pixel_count = PIXEL_COUNT.load(Ordering::SeqCst);
|
||||
let pixel_count = PIXEL_COUNT.load(Ordering::SeqCst);
|
||||
let ray_count = RAY_COUNT.load(Ordering::SeqCst);
|
||||
let time_diff = now - last_time;
|
||||
let pixel_diff = pixel_count - last_pixel_count;
|
||||
let ray_diff = ray_count - last_ray_count;
|
||||
info!(
|
||||
"{} / {} ({}%) pixels rendered {} p/s",
|
||||
pixel_count,
|
||||
pixel_total,
|
||||
"{} / {} ({}%) pixels {} pixels/s {} rays/s",
|
||||
human.format(pixel_count as f64),
|
||||
human.format(pixel_total as f64),
|
||||
100 * pixel_count / pixel_total,
|
||||
pixel_diff as u64 / time_diff.as_secs()
|
||||
human.format(pixel_diff as f64 / time_diff.as_secs_f64()),
|
||||
human.format(ray_diff as f64 / time_diff.as_secs_f64())
|
||||
);
|
||||
last_time = now;
|
||||
last_pixel_count = pixel_count;
|
||||
last_ray_count = ray_count;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user