Skip to repository content

tenant.openagents/omega

No repository description is available.

OpenAgents Git authority 2026-07-28T04:45:43.529Z Public web read
NIP-34 coordinate30617:7649603503856e5148d571eac2766b288a8ff1e9e35d380337a1d2b0015b4f92:omega
MaintainersHidden in public view
References2 branches · 1 tag
Read-only clonegit clone https://openagents.com/git/tenant.openagents/omega.git
Browse files

performance_metrics_overlay.rs

83 lines · 2.8 KB · rust
1//! Performance metrics overlay for CSV preview debugging.
2//!
3//! Provides a semi-transparent overlay in the bottom-right corner showing
4//! CSV parsing performance metrics for developer experience.
5
6use ui::{ActiveTheme, Context, IntoElement, ParentElement, Styled, StyledTypography, div};
7
8use crate::{CsvPreviewView, PerformanceMetrics};
9
10impl CsvPreviewView {
11    /// Renders a semi-transparent performance metrics overlay in the bottom-right corner.
12    ///
13    /// Shows CSV parsing duration for debugging and performance monitoring.
14    /// The overlay is positioned absolutely and styled with reduced opacity.
15    pub(crate) fn render_performance_metrics_overlay(
16        &mut self,
17        cx: &mut Context<Self>,
18    ) -> impl IntoElement {
19        let theme = cx.theme();
20
21        let children = div()
22            .absolute()
23            .bottom_8()
24            .right_4()
25            .px_3()
26            .py_2()
27            .bg(theme.colors().editor_background)
28            .border_1()
29            .border_color(theme.colors().border)
30            .rounded_md()
31            .opacity(0.75)
32            .text_xs()
33            .font_buffer(cx)
34            .text_color(theme.colors().text_muted)
35            .flex()
36            .flex_col()
37            .gap_1()
38            .child("Performance metrics:")
39            .children(
40                format_performance_metrics(&self.performance_metrics)
41                    .into_iter()
42                    .map(|line| div().child(line)),
43            );
44
45        // Clear rendered indices to prepare for next frame
46        self.performance_metrics.rendered_indices.clear();
47        children
48    }
49}
50
51fn format_performance_metrics(metrics: &PerformanceMetrics) -> Vec<String> {
52    let mut lines = Vec::new();
53
54    // Add timing metrics using the display method
55    let timing_display = metrics.display();
56    if !timing_display.is_empty() {
57        lines.extend(timing_display.lines().map(|line| format!("- {}", line)));
58    } else {
59        lines.push("- No timing data yet".to_string());
60    }
61
62    // Add rendered indices information
63    if metrics.rendered_indices.is_empty() {
64        lines.push("- Rendered: none".to_string());
65    } else {
66        lines.push(format!(
67            "- Rendered: {} rows",
68            metrics.rendered_indices.len()
69        ));
70        if metrics.rendered_indices.len() <= 20 {
71            // Show indices if not too many
72            lines.push(format!("  {:?}", metrics.rendered_indices));
73        } else {
74            // Show first/last few if too many
75            let first_few = &metrics.rendered_indices[..5];
76            let last_few = &metrics.rendered_indices[metrics.rendered_indices.len() - 5..];
77            lines.push(format!("  {:?}\n..{:?}", first_few, last_few));
78        }
79    }
80
81    lines
82}
83
Served at tenant.openagents/omega Member data and write actions are omitted.