From 6c60859407a39e579a9f7101b254c874af85ca68 Mon Sep 17 00:00:00 2001 From: Nayeem Rahman Date: Wed, 25 Oct 2023 04:13:16 +0100 Subject: [PATCH] build: fix lsp benchmark (#20969) --- cli/bench/lsp.rs | 47 ++++++++----------------------- cli/bench/lsp_bench_standalone.rs | 10 +------ 2 files changed, 12 insertions(+), 45 deletions(-) diff --git a/cli/bench/lsp.rs b/cli/bench/lsp.rs index a449c9350e..5f3bc50fc3 100644 --- a/cli/bench/lsp.rs +++ b/cli/bench/lsp.rs @@ -45,6 +45,7 @@ fn bench_big_file_edits(deno_exe: &Path) -> Duration { .deno_exe(deno_exe) .build(); client.initialize_default(); + client.change_configuration(json!({ "deno": { "enable": true } })); client.write_notification( "textDocument/didOpen", @@ -58,16 +59,6 @@ fn bench_big_file_edits(deno_exe: &Path) -> Duration { }), ); - let (id, method, _): (u64, String, Option) = client.read_request(); - assert_eq!(method, "workspace/configuration"); - - client.write_response( - id, - json!({ - "enable": true - }), - ); - let (method, _): (String, Option) = client.read_notification(); assert_eq!(method, "textDocument/publishDiagnostics"); let (method, _): (String, Option) = client.read_notification(); @@ -110,6 +101,14 @@ fn bench_code_lens(deno_exe: &Path) -> Duration { .deno_exe(deno_exe) .build(); client.initialize_default(); + client.change_configuration(json!({ "deno": { + "enable": true, + "codeLens": { + "implementations": true, + "references": true, + "test": true, + }, + } })); client.write_notification( "textDocument/didOpen", @@ -123,16 +122,6 @@ fn bench_code_lens(deno_exe: &Path) -> Duration { }), ); - let (id, method, _): (u64, String, Option) = client.read_request(); - assert_eq!(method, "workspace/configuration"); - - client.write_response( - id, - json!({ - "enable": true - }), - ); - let (method, _): (String, Option) = client.read_notification(); assert_eq!(method, "textDocument/publishDiagnostics"); let (method, _): (String, Option) = client.read_notification(); @@ -163,6 +152,7 @@ fn bench_find_replace(deno_exe: &Path) -> Duration { .deno_exe(deno_exe) .build(); client.initialize_default(); + client.change_configuration(json!({ "deno": { "enable": true } })); for i in 0..10 { client.write_notification( @@ -178,12 +168,6 @@ fn bench_find_replace(deno_exe: &Path) -> Duration { ); } - for _ in 0..10 { - let (id, method, _) = client.read_request::(); - assert_eq!(method, "workspace/configuration"); - client.write_response(id, json!({ "enable": true })); - } - for _ in 0..3 { let (method, _): (String, Option) = client.read_notification(); assert_eq!(method, "textDocument/publishDiagnostics"); @@ -252,6 +236,7 @@ fn bench_startup_shutdown(deno_exe: &Path) -> Duration { .deno_exe(deno_exe) .build(); client.initialize_default(); + client.change_configuration(json!({ "deno": { "enable": true } })); client.write_notification( "textDocument/didOpen", @@ -265,16 +250,6 @@ fn bench_startup_shutdown(deno_exe: &Path) -> Duration { }), ); - let (id, method, _) = client.read_request::(); - assert_eq!(method, "workspace/configuration"); - - client.write_response( - id, - json!({ - "enable": true - }), - ); - let (method, _): (String, Option) = client.read_notification(); assert_eq!(method, "textDocument/publishDiagnostics"); let (method, _): (String, Option) = client.read_notification(); diff --git a/cli/bench/lsp_bench_standalone.rs b/cli/bench/lsp_bench_standalone.rs index b3b1f2d920..bd89a5e312 100644 --- a/cli/bench/lsp_bench_standalone.rs +++ b/cli/bench/lsp_bench_standalone.rs @@ -13,6 +13,7 @@ use test_util::lsp::LspClientBuilder; fn incremental_change_wait(bench: &mut Bencher) { let mut client = LspClientBuilder::new().use_diagnostic_sync(false).build(); client.initialize_default(); + client.change_configuration(json!({ "deno": { "enable": true } })); client.write_notification( "textDocument/didOpen", @@ -26,15 +27,6 @@ fn incremental_change_wait(bench: &mut Bencher) { }), ); - let (id, method, _): (u64, String, Option) = client.read_request(); - assert_eq!(method, "workspace/configuration"); - client.write_response( - id, - json!({ - "enable": true - }), - ); - let (method, _maybe_diag): (String, Option) = client.read_notification(); assert_eq!(method, "textDocument/publishDiagnostics");