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:
Myriad-Dreamin 2025-08-12 04:40:04 +08:00 committed by GitHub
parent ce5ab81760
commit f7f2760520
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
17 changed files with 37 additions and 30 deletions

View file

@ -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(),
}
}

View file

@ -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;

View file

@ -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);

View file

@ -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 {