Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
perf: Add on search + fixups (#40537)
Nia438c89081620
diff --git a/Cargo.lock b/Cargo.lockindex e85c8adaad7..cca144a2bfd 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.tomlindex 3f06b422871..e6bea2e4dd6 100644--- a/crates/search/Cargo.toml+++ b/crates/search/Cargo.toml@@ -39,6 +39,7 @@ smol.workspace = truetheme.workspace = trueui.workspace = trueutil.workspace = true+util_macros.workspace = trueworkspace.workspace = truezed_actions.workspace = truediff --git a/crates/search/src/buffer_search.rs b/crates/search/src/buffer_search.rsindex 84be8445329..923e30e0b68 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::<Vec<_>>()}+ #[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.rsindex 1373c7d8454..c292d05df75 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.rsindex 5c050cf5b13..535f25a2b31 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.rsindex c5a251a3e39..1e6ddedf11e 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)