summaryrefslogtreecommitdiff
path: root/cli/lsp/performance.rs
diff options
context:
space:
mode:
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();