mirror of
https://github.com/denoland/deno.git
synced 2025-08-04 02:48:24 +00:00
feat(lsp): add deno cache code actions (#9471)
This commit is contained in:
parent
46da7c6aff
commit
d6c05b09dd
9 changed files with 488 additions and 162 deletions
|
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue