perf(ui-gpui): add render counters, remove redundant cx.observe, reduce repaints
This commit is contained in:
parent
8dd3d82d31
commit
7ab5d97352
2 changed files with 22 additions and 9 deletions
|
|
@ -7,10 +7,14 @@
|
|||
//! The epoch counter cancels stale timers automatically.
|
||||
|
||||
use gpui::*;
|
||||
use std::sync::atomic::{AtomicU64, Ordering};
|
||||
use std::time::Duration;
|
||||
|
||||
use crate::theme;
|
||||
|
||||
static RENDER_COUNT: AtomicU64 = AtomicU64::new(0);
|
||||
static BLINK_COUNT: AtomicU64 = AtomicU64::new(0);
|
||||
|
||||
#[derive(Clone, Copy, PartialEq)]
|
||||
pub enum DotStatus {
|
||||
Running,
|
||||
|
|
@ -62,6 +66,7 @@ impl PulsingDot {
|
|||
this.update(cx, |dot, cx| {
|
||||
// Epoch guard: if epoch changed (pause/resume), this timer is stale
|
||||
if dot.blink_epoch == epoch {
|
||||
BLINK_COUNT.fetch_add(1, Ordering::Relaxed);
|
||||
dot.visible = !dot.visible;
|
||||
cx.notify(); // marks ONLY this view dirty
|
||||
dot.schedule_blink(epoch, cx); // recursive schedule
|
||||
|
|
@ -83,6 +88,11 @@ impl PulsingDot {
|
|||
|
||||
impl Render for PulsingDot {
|
||||
fn render(&mut self, _window: &mut Window, _cx: &mut Context<Self>) -> impl IntoElement {
|
||||
let rc = RENDER_COUNT.fetch_add(1, Ordering::Relaxed);
|
||||
if rc % 60 == 0 {
|
||||
let bc = BLINK_COUNT.load(Ordering::Relaxed);
|
||||
eprintln!("[PulsingDot] renders={rc} blinks={bc} (renders should be ~2x blinks)");
|
||||
}
|
||||
let color = self.color();
|
||||
let r = (color.r * 255.0) as u32;
|
||||
let g = (color.g * 255.0) as u32;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue