From 17aea0573ea33014057a3b8a9443260f585c4223 Mon Sep 17 00:00:00 2001 From: Nico Burns Date: Wed, 14 Aug 2024 19:14:12 +1200 Subject: [PATCH] Add network request logging --- packages/dom/src/util.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/dom/src/util.rs b/packages/dom/src/util.rs index 60e87306..f97daa34 100644 --- a/packages/dom/src/util.rs +++ b/packages/dom/src/util.rs @@ -1,6 +1,6 @@ use std::{ io::{Cursor, Read}, - sync::{Arc, OnceLock}, + sync::{Arc, OnceLock}, time::Instant, }; use crate::node::{Node, NodeData}; @@ -33,6 +33,8 @@ impl From for FetchErr { } pub(crate) fn fetch_blob(url: &str) -> Result, FetchErr> { + let start = Instant::now(); + // Handle data URIs if url.starts_with("data:") { let data_url = data_url::DataUrl::process(url).unwrap(); @@ -63,6 +65,9 @@ pub(crate) fn fetch_blob(url: &str) -> Result, FetchErr> { .read_to_end(&mut bytes) .unwrap(); + let time = (Instant::now() - start).as_millis(); + println!("Fetched {} in {}ms", url, time); + Ok(bytes) }