From 438c890816203f9402981022b80e15b0731ffd86 Mon Sep 17 00:00:00 2001 From: Nia Date: Sat, 18 Oct 2025 00:11:09 +0200 Subject: [PATCH] perf: Add on search + fixups (#40537) Release Notes: - N/A *or* Added/Fixed/Improved ... --- Cargo.lock | 1 + crates/search/Cargo.toml | 1 + crates/search/src/buffer_search.rs | 12 ++++++++++++ crates/search/src/project_search.rs | 11 +++++++++++ tooling/perf/src/implementation.rs | 9 ++++++--- tooling/perf/src/main.rs | 2 +- 6 files changed, 32 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e85c8adaad744c4e7940764c5d6710c8f8344352..cca144a2bfdd90989013eae1d296c5fb6cf6e11c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -14867,6 +14867,7 @@ dependencies = [ "ui", "unindent", "util", + "util_macros", "workspace", "zed_actions", ] diff --git a/crates/search/Cargo.toml b/crates/search/Cargo.toml index 3f06b4228714e67b87d83e69b1afeb2a8cb6a155..e6bea2e4dd634ca915242f8d86fc31e22bb61c95 100644 --- a/crates/search/Cargo.toml +++ b/crates/search/Cargo.toml @@ -39,6 +39,7 @@ smol.workspace = true theme.workspace = true ui.workspace = true util.workspace = true +util_macros.workspace = true workspace.workspace = true zed_actions.workspace = true diff --git a/crates/search/src/buffer_search.rs b/crates/search/src/buffer_search.rs index 84be844532931eaf8c0ce5ced5bfc56c14a62dd0..923e30e0b6878ad32fd65d210101a5a62fd38687 100644 --- a/crates/search/src/buffer_search.rs +++ b/crates/search/src/buffer_search.rs @@ -1524,6 +1524,7 @@ mod tests { use settings::{SearchSettingsContent, SettingsStore}; use smol::stream::StreamExt as _; use unindent::Unindent as _; + use util_macros::perf; fn init_globals(cx: &mut TestAppContext) { cx.update(|cx| { @@ -1580,6 +1581,7 @@ mod tests { (editor.unwrap(), search_bar, cx) } + #[perf] #[gpui::test] async fn test_search_simple(cx: &mut TestAppContext) { let (editor, search_bar, cx) = init_test(cx); @@ -1860,6 +1862,7 @@ mod tests { .collect::>() } + #[perf] #[gpui::test] async fn test_search_option_handling(cx: &mut TestAppContext) { let (editor, search_bar, cx) = init_test(cx); @@ -1920,6 +1923,7 @@ mod tests { }); } + #[perf] #[gpui::test] async fn test_search_select_all_matches(cx: &mut TestAppContext) { init_globals(cx); @@ -2128,6 +2132,7 @@ mod tests { .unwrap(); } + #[perf] #[gpui::test] async fn test_search_query_with_match_whole_word(cx: &mut TestAppContext) { init_globals(cx); @@ -2213,6 +2218,7 @@ mod tests { }); } + #[perf] #[gpui::test] async fn test_search_query_history(cx: &mut TestAppContext) { let (_editor, search_bar, cx) = init_test(cx); @@ -2362,6 +2368,7 @@ mod tests { }); } + #[perf] #[gpui::test] async fn test_replace_simple(cx: &mut TestAppContext) { let (editor, search_bar, cx) = init_test(cx); @@ -2529,6 +2536,7 @@ mod tests { ); } + #[perf] #[gpui::test] async fn test_replace_special_characters(cx: &mut TestAppContext) { let (editor, search_bar, cx) = init_test(cx); @@ -2592,6 +2600,7 @@ mod tests { .await; } + #[perf] #[gpui::test] async fn test_find_matches_in_selections_singleton_buffer_multiple_selections( cx: &mut TestAppContext, @@ -2658,6 +2667,7 @@ mod tests { }); } + #[perf] #[gpui::test] async fn test_find_matches_in_selections_multiple_excerpts_buffer_multiple_selections( cx: &mut TestAppContext, @@ -2744,6 +2754,7 @@ mod tests { }); } + #[perf] #[gpui::test] async fn test_invalid_regexp_search_after_valid(cx: &mut TestAppContext) { let (editor, search_bar, cx) = init_test(cx); @@ -2779,6 +2790,7 @@ mod tests { }); } + #[perf] #[gpui::test] async fn test_search_options_changes(cx: &mut TestAppContext) { let (_editor, search_bar, cx) = init_test(cx); diff --git a/crates/search/src/project_search.rs b/crates/search/src/project_search.rs index 1373c7d8454c9e31681d8365f167026f666cb429..c292d05df75ad329c608d456aaf07a9d1d3af044 100644 --- a/crates/search/src/project_search.rs +++ b/crates/search/src/project_search.rs @@ -2359,8 +2359,10 @@ pub mod tests { use serde_json::json; use settings::SettingsStore; use util::{path, paths::PathStyle, rel_path::rel_path}; + use util_macros::perf; use workspace::DeploySearch; + #[perf] #[gpui::test] async fn test_project_search(cx: &mut TestAppContext) { init_test(cx); @@ -2498,6 +2500,7 @@ pub mod tests { .unwrap(); } + #[perf] #[gpui::test] async fn test_deploy_project_search_focus(cx: &mut TestAppContext) { init_test(cx); @@ -2738,6 +2741,7 @@ pub mod tests { }).unwrap(); } + #[perf] #[gpui::test] async fn test_filters_consider_toggle_state(cx: &mut TestAppContext) { init_test(cx); @@ -2858,6 +2862,7 @@ pub mod tests { .unwrap(); } + #[perf] #[gpui::test] async fn test_new_project_search_focus(cx: &mut TestAppContext) { init_test(cx); @@ -3153,6 +3158,7 @@ pub mod tests { });}).unwrap(); } + #[perf] #[gpui::test] async fn test_new_project_search_in_directory(cx: &mut TestAppContext) { init_test(cx); @@ -3279,6 +3285,7 @@ pub mod tests { .unwrap(); } + #[perf] #[gpui::test] async fn test_search_query_history(cx: &mut TestAppContext) { init_test(cx); @@ -3609,6 +3616,7 @@ pub mod tests { .unwrap(); } + #[perf] #[gpui::test] async fn test_search_query_history_with_multiple_views(cx: &mut TestAppContext) { init_test(cx); @@ -3832,6 +3840,7 @@ pub mod tests { assert_eq!(active_query(&search_view_1, cx), ""); } + #[perf] #[gpui::test] async fn test_deploy_search_with_multiple_panes(cx: &mut TestAppContext) { init_test(cx); @@ -3991,6 +4000,7 @@ pub mod tests { .unwrap(); } + #[perf] #[gpui::test] async fn test_scroll_search_results_to_top(cx: &mut TestAppContext) { init_test(cx); @@ -4071,6 +4081,7 @@ pub mod tests { .expect("unable to update search view"); } + #[perf] #[gpui::test] async fn test_buffer_search_query_reused(cx: &mut TestAppContext) { init_test(cx); diff --git a/tooling/perf/src/implementation.rs b/tooling/perf/src/implementation.rs index 5c050cf5b136f5dfa58c419057b28d53cf529465..535f25a2b312133d5ef446a668b50f2bcdef7489 100644 --- a/tooling/perf/src/implementation.rs +++ b/tooling/perf/src/implementation.rs @@ -420,13 +420,16 @@ impl std::fmt::Display for PerfReport { for (cat, delta) in sorted.into_iter().rev() { const SIGN_POS: &str = "↑"; const SIGN_NEG: &str = "↓"; - const SIGN_NEUTRAL: &str = "±"; + const SIGN_NEUTRAL_POS: &str = "±↑"; + const SIGN_NEUTRAL_NEG: &str = "±↓"; let prettify = |time: f64| { let sign = if time > 0.05 { SIGN_POS - } else if time < 0.05 && time > -0.05 { - SIGN_NEUTRAL + } else if time > 0. { + SIGN_NEUTRAL_POS + } else if time > -0.05 { + SIGN_NEUTRAL_NEG } else { SIGN_NEG }; diff --git a/tooling/perf/src/main.rs b/tooling/perf/src/main.rs index c5a251a3e3920248278813236509435dadb86525..1e6ddedf11e2c5f265d3d4dd93785afbf7f565d2 100644 --- a/tooling/perf/src/main.rs +++ b/tooling/perf/src/main.rs @@ -228,8 +228,8 @@ fn compare_profiles(args: &[String]) { a.strip_prefix("--save=") .expect("FATAL: save param formatted incorrectly"), ); + ident_idx = 1; } - ident_idx = 1; }); let ident_new = args .get(ident_idx)