]> git.lizzy.rs Git - rust.git/blobdiff - crates/rust-analyzer/src/integrated_benchmarks.rs
Replaced fold with for loop
[rust.git] / crates / rust-analyzer / src / integrated_benchmarks.rs
index 3dcbe397ad83bb838236e23536f95f110754085e..c745af3da69342bf3ea77bd07f9c6284113c0432 100644 (file)
 //! in release mode in VS Code. There's however "Rust Analyzer: Copy Run Command Line"
 //! which you can use to paste the command in terminal and add `--release` manually.
 
-use std::{convert::TryFrom, sync::Arc};
+use std::sync::Arc;
 
 use ide::{Change, CompletionConfig, FilePosition, TextSize};
-use ide_db::helpers::{insert_use::InsertUseConfig, merge_imports::MergeBehavior, SnippetCap};
+use ide_db::helpers::{
+    insert_use::{ImportGranularity, InsertUseConfig},
+    SnippetCap,
+};
+use project_model::CargoConfig;
 use test_utils::project_root;
 use vfs::{AbsPathBuf, VfsPath};
 
@@ -29,11 +33,11 @@ fn integrated_highlighting_benchmark() {
     let workspace_to_load = project_root();
     let file = "./crates/ide_db/src/apply_change.rs";
 
-    let cargo_config = Default::default();
+    let cargo_config = CargoConfig::default();
     let load_cargo_config = LoadCargoConfig {
         load_out_dirs_from_check: true,
-        wrap_rustc: false,
         with_proc_macro: false,
+        prefill_caches: false,
     };
 
     let (mut host, vfs, _proc_macro) = {
@@ -83,11 +87,11 @@ fn integrated_completion_benchmark() {
     let workspace_to_load = project_root();
     let file = "./crates/hir/src/lib.rs";
 
-    let cargo_config = Default::default();
+    let cargo_config = CargoConfig::default();
     let load_cargo_config = LoadCargoConfig {
         load_out_dirs_from_check: true,
-        wrap_rustc: false,
         with_proc_macro: false,
+        prefill_caches: true,
     };
 
     let (mut host, vfs, _proc_macro) = {
@@ -123,20 +127,24 @@ fn integrated_completion_benchmark() {
     };
 
     {
-        let _it = stdx::timeit("unqualified path completion");
+        let _p = profile::span("unqualified path completion");
         let _span = profile::cpu_span();
         let analysis = host.analysis();
         let config = CompletionConfig {
             enable_postfix_completions: true,
             enable_imports_on_the_fly: true,
+            enable_self_on_the_fly: true,
             add_call_parenthesis: true,
             add_call_argument_snippets: true,
             snippet_cap: SnippetCap::new(true),
             insert_use: InsertUseConfig {
-                merge: Some(MergeBehavior::Full),
+                granularity: ImportGranularity::Crate,
                 prefix_kind: hir::PrefixKind::ByCrate,
+                enforce_granularity: true,
                 group: true,
+                skip_glob_imports: true,
             },
+            snippets: Vec::new(),
         };
         let position =
             FilePosition { file_id, offset: TextSize::try_from(completion_offset).unwrap() };
@@ -156,20 +164,24 @@ fn integrated_completion_benchmark() {
     };
 
     {
-        let _it = stdx::timeit("dot completion");
+        let _p = profile::span("dot completion");
         let _span = profile::cpu_span();
         let analysis = host.analysis();
         let config = CompletionConfig {
             enable_postfix_completions: true,
             enable_imports_on_the_fly: true,
+            enable_self_on_the_fly: true,
             add_call_parenthesis: true,
             add_call_argument_snippets: true,
             snippet_cap: SnippetCap::new(true),
             insert_use: InsertUseConfig {
-                merge: Some(MergeBehavior::Full),
+                granularity: ImportGranularity::Crate,
                 prefix_kind: hir::PrefixKind::ByCrate,
+                enforce_granularity: true,
                 group: true,
+                skip_glob_imports: true,
             },
+            snippets: Vec::new(),
         };
         let position =
             FilePosition { file_id, offset: TextSize::try_from(completion_offset).unwrap() };