Add API to track lsp perf on language client level#2996
Add API to track lsp perf on language client level#2996testforstephen merged 4 commits intoredhat-developer:masterfrom
Conversation
|
// @akaroml @Eskibear @CsCherrYY pls help a review on the API design as well. |
src/TracingLanguageClient.ts
Outdated
| sendRequest<R>(method: string, token?: CancellationToken): Promise<R>; | ||
| sendRequest<R>(method: string, param: any, token?: CancellationToken): Promise<R>; | ||
| sendRequest(method: any, ...args) { | ||
| const startAt: number = Date.now(); |
There was a problem hiding this comment.
Would be better to use performance.now(). See: https://developer.mozilla.org/en-US/docs/Web/API/Performance/now
Also, Date.now() may have been impacted by system and user clock adjustments, clock skew, etc. as it is relative to the Unix epoch (1970-01-01T00:00:00Z) and dependent on the system clock. The performance.now() method on the other hand is relative to the timeOrigin property which is a monotonic clock: its current time never decreases and isn't subject to adjustments.
There was a problem hiding this comment.
thanks. Good to know the new API.
The data will like textDocument/completion - 1359.5962999993935 ms with performance.now api. Then the downstream tracer can decide whether to convert the floating point number to integer.
This PR provides an API to easily trace the lsp request performance.
initializerequest on languageClient.start()sendRequest(...)Here is a sample code on how to use this API: