feat(lsp): add deno cache code actions (#9471)

This commit is contained in:
Kitson Kelly 2021-02-12 15:17:48 +11:00 committed by GitHub
parent 46da7c6aff
commit d6c05b09dd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 488 additions and 162 deletions

View file

@ -49,7 +49,7 @@ impl From<PerformanceMark> for PerformanceMeasure {
///
/// The structure will limit the size of measurements to the most recent 1000,
/// and will roll off when that limit is reached.
#[derive(Debug)]
#[derive(Debug, Clone)]
pub struct Performance {
counts: Arc<Mutex<HashMap<String, u32>>>,
max_size: usize,
@ -127,13 +127,15 @@ impl Performance {
/// 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.
pub fn measure(&self, mark: PerformanceMark) {
pub fn measure(&self, mark: PerformanceMark) -> Duration {
let measure = PerformanceMeasure::from(mark);
let duration = measure.duration;
let mut measures = self.measures.lock().unwrap();
measures.push_back(measure);
while measures.len() > self.max_size {
measures.pop_front();
}
duration
}
}