summaryrefslogtreecommitdiff
path: root/cli/lsp/performance.rs
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2023-12-01 03:54:59 +0100
committerGitHub <noreply@github.com>2023-12-01 03:54:59 +0100
commitfe90ba650d926fb006948499a96c9dabb149eed9 (patch)
tree65c155c8859a0764c187ec7dd17bc7bb1c4e5be8 /cli/lsp/performance.rs
parent5f6181df4a914c0d05ea3d2b63190b9ee2d764ca (diff)
refactor(lsp): log names (#21413)
This commit changes LSP log names by prefixing them, we now have these prefixes: - `lsp.*` - requests coming from the client - `tsc.request.*` - requests coming from clients that are routed to TSC - `tsc.op.*` - ops called by the TS host - `tsc.host.*` - requests that call JavaScript runtime that runs TypeScript compiler host Additionall `Performance::mark` was split into `Performance::mark` and `Performance::mark_with_args` to reduce verbosity of code and logs.
Diffstat (limited to 'cli/lsp/performance.rs')
-rw-r--r--cli/lsp/performance.rs33
1 files changed, 24 insertions, 9 deletions
diff --git a/cli/lsp/performance.rs b/cli/lsp/performance.rs
index 717ae792d..c4e65aa3c 100644
--- a/cli/lsp/performance.rs
+++ b/cli/lsp/performance.rs
@@ -132,10 +132,7 @@ impl Performance {
.collect()
}
- /// Marks the start of a measurement which returns a performance mark
- /// structure, which is then passed to `.measure()` to finalize the duration
- /// and add it to the internal buffer.
- pub fn mark<S: AsRef<str>, V: Serialize>(
+ fn mark_inner<S: AsRef<str>, V: Serialize>(
&self,
name: S,
maybe_args: Option<V>,
@@ -165,6 +162,24 @@ impl Performance {
}
}
+ /// Marks the start of a measurement which returns a performance mark
+ /// structure, which is then passed to `.measure()` to finalize the duration
+ /// and add it to the internal buffer.
+ pub fn mark<S: AsRef<str>>(&self, name: S) -> PerformanceMark {
+ self.mark_inner(name, None::<()>)
+ }
+
+ /// Marks the start of a measurement which returns a performance mark
+ /// structure, which is then passed to `.measure()` to finalize the duration
+ /// and add it to the internal buffer.
+ pub fn mark_with_args<S: AsRef<str>, V: Serialize>(
+ &self,
+ name: S,
+ args: V,
+ ) -> PerformanceMark {
+ self.mark_inner(name, Some(args))
+ }
+
/// A function which accepts a previously created performance mark which will
/// be used to finalize the duration of the span being measured, and add the
/// measurement to the internal buffer.
@@ -201,9 +216,9 @@ mod tests {
#[test]
fn test_average() {
let performance = Performance::default();
- let mark1 = performance.mark("a", None::<()>);
- let mark2 = performance.mark("a", None::<()>);
- let mark3 = performance.mark("b", None::<()>);
+ let mark1 = performance.mark("a");
+ let mark2 = performance.mark("a");
+ let mark3 = performance.mark("b");
performance.measure(mark2);
performance.measure(mark1);
performance.measure(mark3);
@@ -217,8 +232,8 @@ mod tests {
#[test]
fn test_averages() {
let performance = Performance::default();
- let mark1 = performance.mark("a", None::<()>);
- let mark2 = performance.mark("a", None::<()>);
+ let mark1 = performance.mark("a");
+ let mark2 = performance.mark("a");
performance.measure(mark2);
performance.measure(mark1);
let averages = performance.averages();