mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-30 13:51:16 +00:00
[ty] Add debug output with completion request timings
I had this in a branch somewhere but forgot to get it merged. So I'm sneaking it in here. This is useful for very ad hoc performance testing.
This commit is contained in:
parent
c9df4ddf6a
commit
6ea231e458
1 changed files with 8 additions and 0 deletions
|
@ -1,4 +1,5 @@
|
|||
use std::borrow::Cow;
|
||||
use std::time::Instant;
|
||||
|
||||
use lsp_types::request::Completion;
|
||||
use lsp_types::{CompletionItem, CompletionItemKind, CompletionParams, CompletionResponse, Url};
|
||||
|
@ -31,6 +32,8 @@ impl BackgroundDocumentRequestHandler for CompletionRequestHandler {
|
|||
_client: &Client,
|
||||
params: CompletionParams,
|
||||
) -> crate::server::Result<Option<CompletionResponse>> {
|
||||
let start = Instant::now();
|
||||
|
||||
if snapshot.client_settings().is_language_services_disabled() {
|
||||
return Ok(None);
|
||||
}
|
||||
|
@ -66,7 +69,12 @@ impl BackgroundDocumentRequestHandler for CompletionRequestHandler {
|
|||
}
|
||||
})
|
||||
.collect();
|
||||
let len = items.len();
|
||||
let response = CompletionResponse::Array(items);
|
||||
tracing::debug!(
|
||||
"Completions request returned {len} suggestions in {elapsed:?}",
|
||||
elapsed = Instant::now().duration_since(start)
|
||||
);
|
||||
Ok(Some(response))
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue