1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-21 15:04:11 -05:00

build: fix lsp benchmark (#20969)

This commit is contained in:
Nayeem Rahman 2023-10-25 04:13:16 +01:00 committed by GitHub
parent bc53b588d0
commit 6c60859407
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 45 deletions

View file

@ -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<Value>) = client.read_request();
assert_eq!(method, "workspace/configuration");
client.write_response(
id,
json!({
"enable": true
}),
);
let (method, _): (String, Option<Value>) = client.read_notification();
assert_eq!(method, "textDocument/publishDiagnostics");
let (method, _): (String, Option<Value>) = 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<Value>) = client.read_request();
assert_eq!(method, "workspace/configuration");
client.write_response(
id,
json!({
"enable": true
}),
);
let (method, _): (String, Option<Value>) = client.read_notification();
assert_eq!(method, "textDocument/publishDiagnostics");
let (method, _): (String, Option<Value>) = 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::<Value>();
assert_eq!(method, "workspace/configuration");
client.write_response(id, json!({ "enable": true }));
}
for _ in 0..3 {
let (method, _): (String, Option<Value>) = 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::<Value>();
assert_eq!(method, "workspace/configuration");
client.write_response(
id,
json!({
"enable": true
}),
);
let (method, _): (String, Option<Value>) = client.read_notification();
assert_eq!(method, "textDocument/publishDiagnostics");
let (method, _): (String, Option<Value>) = client.read_notification();

View file

@ -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<Value>) = client.read_request();
assert_eq!(method, "workspace/configuration");
client.write_response(
id,
json!({
"enable": true
}),
);
let (method, _maybe_diag): (String, Option<Value>) =
client.read_notification();
assert_eq!(method, "textDocument/publishDiagnostics");