Skip to content

Commit

Permalink
HACKS: Log frames per second of render loop
Browse files Browse the repository at this point in the history
  • Loading branch information
the-mikedavis committed Oct 5, 2022
1 parent c927d61 commit 02ae7ad
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
16 changes: 16 additions & 0 deletions helix-term/src/application.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -301,26 +303,31 @@ impl Application {

if last || self.last_render.elapsed() > LSP_DEADLINE {
self.render();
iterations = iterations.saturating_add(1);
self.last_render = Instant::now();
}
}
Some(payload) = self.editor.debugger_events.next() => {
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
Expand All @@ -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
Expand Down
4 changes: 4 additions & 0 deletions helix-view/src/editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -676,6 +676,8 @@ pub struct Editor {
pub auto_pairs: Option<AutoPairs>,

pub idle_timer: Pin<Box<Sleep>>,
pub immediate_timer: Pin<Box<Sleep>>,
pub frame_timer: Pin<Box<Sleep>>,
pub last_motion: Option<Motion>,

pub last_completion: Option<CompleteAction>,
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 02ae7ad

Please sign in to comment.