Skip to content

Commit

Permalink
Add training time to stats panel
Browse files Browse the repository at this point in the history
  • Loading branch information
ArthurBrussee committed Nov 19, 2024
1 parent 0b73a61 commit 2d18ca4
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 1 deletion.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ tokio-util = { version = "0.7.12", features = ["io"] }
reqwest = { version = "0.12.9", features = ["stream"] }

web-time = "1.1.0"
humantime = "2.1.0"

tracing-wasm = "0.2.1"
async-fn-stream = "0.2.2"
Expand Down
1 change: 1 addition & 0 deletions crates/brush-viewer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ tracing-subscriber.workspace = true
rand.workspace = true

web-time.workspace = true
humantime.workspace = true

log.workspace = true
gloo-timers.workspace = true
Expand Down
12 changes: 11 additions & 1 deletion crates/brush-viewer/src/panels/stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use crate::{
};
use burn_jit::cubecl::Runtime;
use burn_wgpu::{WgpuDevice, WgpuRuntime};
use std::{collections::VecDeque, sync::Arc};
use std::{collections::VecDeque, sync::Arc, time::Duration};
use web_time::Instant;
use wgpu::AdapterInfo;

Expand All @@ -19,6 +19,7 @@ pub(crate) struct StatsPanel {
training_started: bool,
num_splats: usize,

start_load_time: Instant,
adapter_info: AdapterInfo,
}

Expand All @@ -33,6 +34,7 @@ impl StatsPanel {
last_eval_psnr: None,
training_started: false,
num_splats: 0,
start_load_time: Instant::now(),
adapter_info,
}
}
Expand Down Expand Up @@ -66,6 +68,7 @@ impl ViewerPanel for StatsPanel {
fn on_message(&mut self, message: crate::viewer::ViewerMessage, _: &mut ViewerContext) {
match message {
ViewerMessage::StartLoading { training } => {
self.start_load_time = Instant::now();
self.last_train_step = (Instant::now(), 0);
self.train_iter_per_s = 0.0;
self.train_iter_history.clear();
Expand Down Expand Up @@ -129,6 +132,13 @@ impl ViewerPanel for StatsPanel {
"--".to_owned()
});
ui.end_row();

ui.label("Training time");
// Round duration to seconds.
let elapsed =
Duration::from_secs((Instant::now() - self.start_load_time).as_secs());
ui.label(format!("{}", humantime::Duration::from(elapsed)));
ui.end_row();
}

let client = WgpuRuntime::client(&self.device);
Expand Down

0 comments on commit 2d18ca4

Please sign in to comment.