mirror of
https://github.com/Myriad-Dreamin/tinymist.git
synced 2025-11-23 12:46:43 +00:00
feat: use tinymist_std::time for wasm32 targets (#2028)
`std::time` are not implemented for wasm32 targets, so we should use the time crate made by ourselves.
This commit is contained in:
parent
ce5ab81760
commit
f7f2760520
17 changed files with 37 additions and 30 deletions
|
|
@ -1089,7 +1089,7 @@ impl SharedContext {
|
|||
let entry = entry.entry(query).or_default();
|
||||
QueryStatGuard {
|
||||
bucket: entry.clone(),
|
||||
since: std::time::SystemTime::now(),
|
||||
since: tinymist_std::time::Instant::now(),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,9 +1,10 @@
|
|||
//! Statistics about the analyzers
|
||||
|
||||
use std::{sync::Arc, time::Duration};
|
||||
use std::sync::Arc;
|
||||
|
||||
use parking_lot::Mutex;
|
||||
use tinymist_std::hash::FxDashMap;
|
||||
use tinymist_std::time::Duration;
|
||||
use typst::syntax::FileId;
|
||||
|
||||
#[derive(Clone)]
|
||||
|
|
@ -35,12 +36,12 @@ pub(crate) struct QueryStatBucket {
|
|||
|
||||
pub(crate) struct QueryStatGuard {
|
||||
pub bucket: QueryStatBucket,
|
||||
pub since: std::time::SystemTime,
|
||||
pub since: tinymist_std::time::Instant,
|
||||
}
|
||||
|
||||
impl Drop for QueryStatGuard {
|
||||
fn drop(&mut self) {
|
||||
let elapsed = self.since.elapsed().unwrap_or_default();
|
||||
let elapsed = self.since.elapsed();
|
||||
let mut data = self.bucket.data.lock();
|
||||
data.query += 1;
|
||||
data.total += elapsed;
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ pub(crate) fn type_check(
|
|||
module_exports: Default::default(),
|
||||
};
|
||||
|
||||
let type_check_start = std::time::Instant::now();
|
||||
let type_check_start = tinymist_std::time::Instant::now();
|
||||
|
||||
checker.check(&root);
|
||||
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ pub(crate) fn get_lexical_hierarchy(
|
|||
source: &Source,
|
||||
scope_kind: LexicalScopeKind,
|
||||
) -> Option<EcoVec<LexicalHierarchy>> {
|
||||
let start = std::time::Instant::now();
|
||||
let start = tinymist_std::time::Instant::now();
|
||||
let root = LinkedNode::new(source.root());
|
||||
|
||||
let mut worker = LexicalHierarchyWorker {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue