From 02ae7adc8a0214b105dc441a6cb2f3ea89f1e4fb Mon Sep 17 00:00:00 2001 From: Michael Davis Date: Tue, 4 Oct 2022 21:45:05 -0500 Subject: [PATCH] HACKS: Log frames per second of render loop --- helix-term/src/application.rs | 16 ++++++++++++++++ helix-view/src/editor.rs | 4 ++++ 2 files changed, 20 insertions(+) diff --git a/helix-term/src/application.rs b/helix-term/src/application.rs index c7d98fcec0ddb..1542f4407ed8c 100644 --- a/helix-term/src/application.rs +++ b/helix-term/src/application.rs @@ -278,6 +278,8 @@ impl Application { #[cfg(feature = "integration")] let mut idle_handled = false; + let mut iterations: usize = 0; + loop { if self.editor.should_close() { return false; @@ -301,6 +303,7 @@ impl Application { if last || self.last_render.elapsed() > LSP_DEADLINE { self.render(); + iterations = iterations.saturating_add(1); self.last_render = Instant::now(); } } @@ -308,19 +311,23 @@ impl Application { let needs_render = self.editor.handle_debugger_message(payload).await; if needs_render { self.render(); + iterations = iterations.saturating_add(1); } } Some(config_event) = self.editor.config_events.1.recv() => { self.handle_config_events(config_event); self.render(); + iterations = iterations.saturating_add(1); } Some(callback) = self.jobs.futures.next() => { self.jobs.handle_callback(&mut self.editor, &mut self.compositor, callback); self.render(); + iterations = iterations.saturating_add(1); } Some(callback) = self.jobs.wait_futures.next() => { self.jobs.handle_callback(&mut self.editor, &mut self.compositor, callback); self.render(); + iterations = iterations.saturating_add(1); } _ = &mut self.editor.idle_timer => { // idle timeout @@ -332,6 +339,15 @@ impl Application { idle_handled = true; } } + _ = &mut self.editor.frame_timer => { + log::warn!("🏎️: {}", iterations); + self.editor.frame_timer.as_mut().reset(tokio::time::Instant::now() + Duration::from_secs(1)); + iterations = 0; + } + _ = &mut self.editor.immediate_timer => { + self.render(); + iterations = iterations.saturating_add(1); + } } // for integration tests only, reset the idle timer after every diff --git a/helix-view/src/editor.rs b/helix-view/src/editor.rs index d09d0ac3eebaf..145070c2c0995 100644 --- a/helix-view/src/editor.rs +++ b/helix-view/src/editor.rs @@ -676,6 +676,8 @@ pub struct Editor { pub auto_pairs: Option, pub idle_timer: Pin>, + pub immediate_timer: Pin>, + pub frame_timer: Pin>, pub last_motion: Option, pub last_completion: Option, @@ -755,6 +757,8 @@ impl Editor { status_msg: None, autoinfo: None, idle_timer: Box::pin(sleep(conf.idle_timeout)), + immediate_timer: Box::pin(sleep(Duration::from_millis(1))), + frame_timer: Box::pin(sleep(Duration::from_secs(1))), last_motion: None, last_completion: None, config,